mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Enlarge the SQLite database cache intelligently.
This commit is contained in:
@@ -24,8 +24,11 @@ LogPartition TaggedCachePartition("TaggedCache");
|
||||
LogPartition AutoSocketPartition("AutoSocket");
|
||||
Application* theApp = NULL;
|
||||
|
||||
int DatabaseCon::sCount = 0;
|
||||
|
||||
DatabaseCon::DatabaseCon(const std::string& strName, const char *initStrings[], int initCount)
|
||||
{
|
||||
++sCount;
|
||||
boost::filesystem::path pPath = (theConfig.RUN_STANDALONE && (theConfig.START_UP != Config::LOAD))
|
||||
? "" // Use temporary files.
|
||||
: (theConfig.DATA_DIR / strName); // Use regular db files.
|
||||
@@ -172,6 +175,9 @@ void Application::setup()
|
||||
mLedgerMaster.tune(theConfig.getSize(siLedgerSize), theConfig.getSize(siLedgerAge));
|
||||
mLedgerMaster.setMinValidations(theConfig.VALIDATION_QUORUM);
|
||||
|
||||
theApp->getHashNodeDB()->getDB()->executeSQL(boost::str(boost::format("PRAGMA cache_size=-%d;") %
|
||||
(theConfig.getSize(siDBCache) * 1024)));
|
||||
|
||||
//
|
||||
// Allow peer connections.
|
||||
//
|
||||
|
||||
@@ -36,12 +36,14 @@ class DatabaseCon
|
||||
protected:
|
||||
Database* mDatabase;
|
||||
boost::recursive_mutex mLock;
|
||||
static int sCount;
|
||||
|
||||
public:
|
||||
DatabaseCon(const std::string& name, const char *initString[], int countInit);
|
||||
~DatabaseCon();
|
||||
Database* getDB() { return mDatabase; }
|
||||
boost::recursive_mutex& getDBLock() { return mLock; }
|
||||
Database* getDB() { return mDatabase; }
|
||||
boost::recursive_mutex& getDBLock() { return mLock; }
|
||||
static int getCount() { return sCount; }
|
||||
};
|
||||
|
||||
class Application
|
||||
|
||||
@@ -486,7 +486,7 @@ void Config::load()
|
||||
|
||||
int Config::getSize(SizedItemName item)
|
||||
{
|
||||
SizedItem sizeTable[] = {
|
||||
SizedItem sizeTable[] = { // tiny small medium large huge
|
||||
{ siSweepInterval, { 10, 30, 60, 90, 90 } },
|
||||
{ siLedgerFetch, { 2, 2, 3, 4, 5 } },
|
||||
{ siValidationsSize, { 256, 256, 512, 1024, 1024 } },
|
||||
@@ -496,7 +496,8 @@ int Config::getSize(SizedItemName item)
|
||||
{ siLedgerSize, { 32, 64, 128, 1024, 0 } },
|
||||
{ siLedgerAge, { 30, 60, 120, 300, 600 } },
|
||||
{ siLineCacheSize, { 8192, 32768, 131072, 1048576, 0 } },
|
||||
{ siLineCacheAge, { 500, 600, 1800, 3600, 7200 } }
|
||||
{ siLineCacheAge, { 500, 600, 1800, 3600, 7200 } },
|
||||
{ siDBCache, { 8, 12, 24, 64, 96 } },
|
||||
};
|
||||
|
||||
for (int i = 0; i < (sizeof(sizeTable) / sizeof(SizedItem)); ++i)
|
||||
|
||||
@@ -64,7 +64,8 @@ enum SizedItemName
|
||||
siLedgerAge,
|
||||
siLedgerFetch,
|
||||
siLineCacheSize,
|
||||
siLineCacheAge
|
||||
siLineCacheAge,
|
||||
siDBCache
|
||||
};
|
||||
|
||||
struct SizedItem
|
||||
|
||||
@@ -2021,9 +2021,19 @@ Json::Value RPCHandler::doGetCounts(Json::Value jvRequest, int& cost)
|
||||
BOOST_FOREACH(InstanceType::InstanceCount& it, count)
|
||||
ret[it.first] = it.second;
|
||||
|
||||
int dbKB = theApp->getLedgerDB()->getDB()->getKBUsed();
|
||||
int dbKB = theApp->getLedgerDB()->getDB()->getKBUsedAll();
|
||||
if (dbKB > 0)
|
||||
ret["dbKB"] = dbKB;
|
||||
ret["dbKBTotal"] = dbKB;
|
||||
|
||||
dbKB = theApp->getLedgerDB()->getDB()->getKBUsedDB();
|
||||
if (dbKB > 0)
|
||||
ret["dbKBLedger"] = dbKB;
|
||||
dbKB = theApp->getHashNodeDB()->getDB()->getKBUsedDB();
|
||||
if (dbKB > 0)
|
||||
ret["dbKBHashNode"] = dbKB;
|
||||
dbKB = theApp->getTxnDB()->getDB()->getKBUsedDB();
|
||||
if (dbKB > 0)
|
||||
ret["dbKBTransaction"] = dbKB;
|
||||
|
||||
std::string uptime;
|
||||
int s = upTime();
|
||||
|
||||
Reference in New Issue
Block a user