Skip to content

Commit eef22b5

Browse files
author
wangchao
committed
adjust cache size and age
1 parent 2d89c28 commit eef22b5

File tree

9 files changed

+26
-3
lines changed

9 files changed

+26
-3
lines changed

src/ripple/app/ledger/LedgerHistory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ LedgerHistory::LedgerHistory (
5353
return ledger->info().validated;
5454
}
5555
,app.journal("TaggedCache"))
56-
, m_consensus_validated ("ConsensusValidated", 64, 300,
56+
, m_consensus_validated ("ConsensusValidated", 64, /*300*/60,
5757
stopwatch(), app_.journal("TaggedCache"))
5858
, j_ (app.journal ("LedgerHistory"))
5959
{

src/ripple/app/ledger/TransactionMaster.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class TransactionMaster
5959

6060
void canonicalize (std::shared_ptr<Transaction>* pTransaction);
6161

62+
void tune(int size, int age);
63+
6264
void sweep (void);
6365

6466
TaggedCache <uint256, Transaction>&

src/ripple/app/ledger/impl/TransactionMaster.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ TransactionMaster::canonicalize(std::shared_ptr<Transaction>* pTransaction)
188188
}
189189
}
190190

191+
void TransactionMaster::tune(int size, int age)
192+
{
193+
mCache.setTargetSize(size);
194+
mCache.setTargetAge(age);
195+
}
196+
191197
void TransactionMaster::sweep (void)
192198
{
193199
mCache.sweep ();

src/ripple/app/main/Application.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,8 @@ class ApplicationImp
426426

427427
, m_collectorManager (CollectorManager::New (
428428
config_->section (SECTION_INSIGHT), logs_->journal("Collector")))
429-
, cachedSLEs_ (std::chrono::minutes(1), stopwatch())
429+
//, cachedSLEs_ (std::chrono::minutes(1), stopwatch())
430+
, cachedSLEs_(std::chrono::seconds(config_->getSize(siSLECacheAge)), stopwatch())
430431
, validatorKeys_(*config_, m_journal)
431432

432433
, m_resourceManager (Resource::make_Manager (
@@ -472,7 +473,7 @@ class ApplicationImp
472473
gotTXSet (set, fromAcquire);
473474
}))
474475

475-
, m_acceptedLedgerCache("AcceptedLedger", /*4*/16, /*60*/600, stopwatch(),
476+
, m_acceptedLedgerCache("AcceptedLedger", 4, 60, stopwatch(),
476477
logs_->journal("TaggedCache"))
477478

478479
, m_networkOPs (make_NetworkOPs (*this, stopwatch(),
@@ -1367,6 +1368,7 @@ bool ApplicationImp::setup()
13671368

13681369
m_nodeStore->tune (config_->getSize (siNodeCacheSize), config_->getSize (siNodeCacheAge));
13691370
m_ledgerMaster->tune (config_->getSize (siLedgerSize), config_->getSize (siLedgerAge));
1371+
m_txMaster.tune (config_->getSize(siTransactionSize), config_->getSize(siTransactionAge));
13701372
family().treecache().setTargetSize (config_->getSize (siTreeCacheSize));
13711373
family().treecache().setTargetAge (config_->getSize (siTreeCacheAge));
13721374

src/ripple/core/Config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ enum SizedItemName
5656
siSLECacheAge,
5757
siLedgerSize,
5858
siLedgerAge,
59+
siTransactionSize,
60+
siTransactionAge,
5961
siLedgerFetch,
6062
siHashNodeDBCache,
6163
siTxnDBCache,

src/ripple/core/impl/Config.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,9 @@ int Config::getSize (SizedItemName item) const
588588
{ siLedgerSize, { 32, 128, 256, 384, 768 } },
589589
{ siLedgerAge, { 30, 90, 180, 240, 900 } },
590590

591+
{ siTransactionSize, { 65536, 131072, 196608, 262144, 327680 } },
592+
{ siTransactionAge, { 60, 90, 120, 900, 1800 } },
593+
591594
{ siHashNodeDBCache, { 4, 12, 24, 64, 128 } },
592595
{ siTxnDBCache, { 4, 12, 24, 64, 128 } },
593596
{ siLgrDBCache, { 4, 8, 16, 32, 128 } },

src/ripple/ledger/CachedSLEs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ class CachedSLEs
9898
double
9999
rate() const;
100100

101+
std::size_t size() const
102+
{
103+
return map_.size();
104+
}
105+
101106
private:
102107
std::size_t hit_ = 0;
103108
std::size_t miss_ = 0;

src/ripple/protocol/JsonFields.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ JSS ( both ); // in: Subscribe, Unsubscribe
138138
JSS ( both_sides ); // in: Subscribe, Unsubscribe
139139
JSS ( build_path ); // in: TransactionSign
140140
JSS ( build_version ); // out: NetworkOPs
141+
JSS ( cachedSLE_size );
141142
JSS ( cancel_after ); // out: AccountChannels
142143
JSS ( can_delete ); // out: CanDelete
143144
JSS ( channel_id ); // out: AccountChannels

src/ripple/rpc/handlers/GetCounts.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ Json::Value doGetCounts (RPC::Context& context)
106106
ret[jss::ledger_hit_rate] = context.app.getLedgerMaster ().getCacheHitRate ();
107107
ret[jss::AL_hit_rate] = context.app.getAcceptedLedgerCache ().getHitRate ();
108108

109+
ret[jss::cachedSLE_size] = static_cast<unsigned int>(context.app.cachedSLEs().size());
110+
109111
ret[jss::fullbelow_size] = static_cast<int>(context.app.family().fullbelow().size());
110112
ret[jss::treenode_cache_size] = context.app.family().treecache().getCacheSize();
111113
ret[jss::treenode_track_size] = context.app.family().treecache().getTrackSize();

0 commit comments

Comments
 (0)