mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Allow tunable node sizes to adjust cache sizes, sweep timing, fetch
timing, and so on. Node size defaults to "tiny", which converves memory and bandwidth.
This commit is contained in:
@@ -211,6 +211,11 @@
|
|||||||
# Examples: RASH BUSH MILK LOOK BAD BRIM AVID GAFF BAIT ROT POD LOVE
|
# Examples: RASH BUSH MILK LOOK BAD BRIM AVID GAFF BAIT ROT POD LOVE
|
||||||
# shfArahZT9Q9ckTf3s1psJ7C7qzVN
|
# shfArahZT9Q9ckTf3s1psJ7C7qzVN
|
||||||
#
|
#
|
||||||
|
# [node_size]:
|
||||||
|
# Tunes the servers based on the expected load and available memory. Legal
|
||||||
|
# sizes are "tiny", "small", "medium", "large", and "huge".
|
||||||
|
# The default is "tiny".
|
||||||
|
#
|
||||||
# [cluster_nodes]:
|
# [cluster_nodes]:
|
||||||
# To extend full trust to other nodes, place their node public keys here.
|
# To extend full trust to other nodes, place their node public keys here.
|
||||||
# Generally, you should only do this for nodes under common administration.
|
# Generally, you should only do this for nodes under common administration.
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ Application::Application() :
|
|||||||
getRand(mNonce256.begin(), mNonce256.size());
|
getRand(mNonce256.begin(), mNonce256.size());
|
||||||
getRand(reinterpret_cast<unsigned char *>(&mNonceST), sizeof(mNonceST));
|
getRand(reinterpret_cast<unsigned char *>(&mNonceST), sizeof(mNonceST));
|
||||||
mJobQueue.setThreadCount();
|
mJobQueue.setThreadCount();
|
||||||
mSweepTimer.expires_from_now(boost::posix_time::seconds(60));
|
mSweepTimer.expires_from_now(boost::posix_time::seconds(20));
|
||||||
mSweepTimer.async_wait(boost::bind(&Application::sweep, this));
|
mSweepTimer.async_wait(boost::bind(&Application::sweep, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,6 +159,9 @@ void Application::setup()
|
|||||||
if (!theConfig.RUN_STANDALONE)
|
if (!theConfig.RUN_STANDALONE)
|
||||||
getUNL().nodeBootstrap();
|
getUNL().nodeBootstrap();
|
||||||
|
|
||||||
|
mValidations.tune(theConfig.getSize(siValidationsSize), theConfig.getSize(siValidationsAge));
|
||||||
|
mHashedObjectStore.tune(theConfig.getSize(siNodeCacheSize), theConfig.getSize(siNodeCacheAge));
|
||||||
|
mLedgerMaster.tune(theConfig.getSize(siLedgerSize), theConfig.getSize(siLedgerAge));
|
||||||
|
|
||||||
//
|
//
|
||||||
// Allow peer connections.
|
// Allow peer connections.
|
||||||
@@ -294,7 +297,7 @@ void Application::sweep()
|
|||||||
mTempNodeCache.sweep();
|
mTempNodeCache.sweep();
|
||||||
mValidations.sweep();
|
mValidations.sweep();
|
||||||
getMasterLedgerAcquire().sweep();
|
getMasterLedgerAcquire().sweep();
|
||||||
mSweepTimer.expires_from_now(boost::posix_time::seconds(60));
|
mSweepTimer.expires_from_now(boost::posix_time::seconds(theConfig.getSize(siSweepInterval)));
|
||||||
mSweepTimer.async_wait(boost::bind(&Application::sweep, this));
|
mSweepTimer.async_wait(boost::bind(&Application::sweep, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#define SECTION_IPS "ips"
|
#define SECTION_IPS "ips"
|
||||||
#define SECTION_NETWORK_QUORUM "network_quorum"
|
#define SECTION_NETWORK_QUORUM "network_quorum"
|
||||||
#define SECTION_NODE_SEED "node_seed"
|
#define SECTION_NODE_SEED "node_seed"
|
||||||
|
#define SECTION_NODE_SIZE "node_size"
|
||||||
#define SECTION_PEER_CONNECT_LOW_WATER "peer_connect_low_water"
|
#define SECTION_PEER_CONNECT_LOW_WATER "peer_connect_low_water"
|
||||||
#define SECTION_PEER_IP "peer_ip"
|
#define SECTION_PEER_IP "peer_ip"
|
||||||
#define SECTION_PEER_PORT "peer_port"
|
#define SECTION_PEER_PORT "peer_port"
|
||||||
@@ -83,6 +84,7 @@ void Config::setup(const std::string& strConf, bool bTestNet, bool bQuiet)
|
|||||||
|
|
||||||
TESTNET = bTestNet;
|
TESTNET = bTestNet;
|
||||||
QUIET = bQuiet;
|
QUIET = bQuiet;
|
||||||
|
NODE_SIZE = 0;
|
||||||
|
|
||||||
// TESTNET forces a "testnet-" prefix on the conf file and db directory.
|
// TESTNET forces a "testnet-" prefix on the conf file and db directory.
|
||||||
strDbPath = TESTNET ? "testnet-db" : "db";
|
strDbPath = TESTNET ? "testnet-db" : "db";
|
||||||
@@ -329,6 +331,28 @@ void Config::load()
|
|||||||
if (sectionSingleB(secConfig, SECTION_RPC_ALLOW_REMOTE, strTemp))
|
if (sectionSingleB(secConfig, SECTION_RPC_ALLOW_REMOTE, strTemp))
|
||||||
RPC_ALLOW_REMOTE = boost::lexical_cast<bool>(strTemp);
|
RPC_ALLOW_REMOTE = boost::lexical_cast<bool>(strTemp);
|
||||||
|
|
||||||
|
if (sectionSingleB(secConfig, SECTION_NODE_SIZE, strTemp))
|
||||||
|
{
|
||||||
|
if (strTemp == "tiny")
|
||||||
|
NODE_SIZE = 0;
|
||||||
|
else if (strTemp == "small")
|
||||||
|
NODE_SIZE = 1;
|
||||||
|
else if (strTemp == "medium")
|
||||||
|
NODE_SIZE = 2;
|
||||||
|
else if (strTemp == "large")
|
||||||
|
NODE_SIZE = 3;
|
||||||
|
else if (strTemp == "huge")
|
||||||
|
NODE_SIZE = 4;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NODE_SIZE = boost::lexical_cast<int>(strTemp);
|
||||||
|
if (NODE_SIZE < 0)
|
||||||
|
NODE_SIZE = 0;
|
||||||
|
else if (NODE_SIZE > 4)
|
||||||
|
NODE_SIZE = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
(void) sectionSingleB(secConfig, SECTION_WEBSOCKET_IP, WEBSOCKET_IP);
|
(void) sectionSingleB(secConfig, SECTION_WEBSOCKET_IP, WEBSOCKET_IP);
|
||||||
|
|
||||||
if (sectionSingleB(secConfig, SECTION_WEBSOCKET_PORT, strTemp))
|
if (sectionSingleB(secConfig, SECTION_WEBSOCKET_PORT, strTemp))
|
||||||
@@ -427,4 +451,27 @@ void Config::load()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Config::getSize(SizedItemName item)
|
||||||
|
{
|
||||||
|
SizedItem sizeTable[] = {
|
||||||
|
{ siSweepInterval, { 10, 30, 60, 90, 90 } },
|
||||||
|
{ siLedgerFetch, { 2, 4, 10, 10, 10 } },
|
||||||
|
{ siValidationsSize, { 256, 256, 512, 1024, 1024 } },
|
||||||
|
{ siValidationsAge, { 500, 500, 500, 500, 500 } },
|
||||||
|
{ siNodeCacheSize, { 8192, 32768, 131072, 1048576, 0 } },
|
||||||
|
{ siNodeCacheAge, { 30, 60, 90, 300, 600 } },
|
||||||
|
{ siLedgerSize, { 32, 64, 128, 1024, 0 } },
|
||||||
|
{ siLedgerAge, { 30, 60, 120, 300, 600 } },
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < (sizeof(sizeTable) / sizeof(SizedItem)); ++i)
|
||||||
|
{
|
||||||
|
if (sizeTable[i].item == item)
|
||||||
|
return sizeTable[i].sizes[NODE_SIZE];
|
||||||
|
}
|
||||||
|
assert(false);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// vim:ts=4
|
// vim:ts=4
|
||||||
|
|||||||
@@ -48,6 +48,24 @@ const int SYSTEM_WEBSOCKET_PUBLIC_PORT = 6563; // XXX Going away.
|
|||||||
// Might connect with fewer for testing.
|
// Might connect with fewer for testing.
|
||||||
#define DEFAULT_PEER_CONNECT_LOW_WATER 4
|
#define DEFAULT_PEER_CONNECT_LOW_WATER 4
|
||||||
|
|
||||||
|
enum SizedItemName
|
||||||
|
{
|
||||||
|
siSweepInterval,
|
||||||
|
siValidationsSize,
|
||||||
|
siValidationsAge,
|
||||||
|
siNodeCacheSize,
|
||||||
|
siNodeCacheAge,
|
||||||
|
siLedgerSize,
|
||||||
|
siLedgerAge,
|
||||||
|
siLedgerFetch,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SizedItem
|
||||||
|
{
|
||||||
|
SizedItemName item;
|
||||||
|
int sizes[5];
|
||||||
|
};
|
||||||
|
|
||||||
class Config
|
class Config
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -139,6 +157,7 @@ public:
|
|||||||
|
|
||||||
// Node storage configuration
|
// Node storage configuration
|
||||||
uint32 LEDGER_HISTORY;
|
uint32 LEDGER_HISTORY;
|
||||||
|
int NODE_SIZE;
|
||||||
|
|
||||||
// Client behavior
|
// Client behavior
|
||||||
int ACCOUNT_PROBE_MAX; // How far to scan for accounts.
|
int ACCOUNT_PROBE_MAX; // How far to scan for accounts.
|
||||||
@@ -150,6 +169,7 @@ public:
|
|||||||
|
|
||||||
Config();
|
Config();
|
||||||
|
|
||||||
|
int getSize(SizedItemName);
|
||||||
void setup(const std::string& strConf, bool bTestNet, bool bQuiet);
|
void setup(const std::string& strConf, bool bTestNet, bool bQuiet);
|
||||||
void load();
|
void load();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ HashedObjectStore::HashedObjectStore(int cacheSize, int cacheAge) :
|
|||||||
mWriteSet.reserve(128);
|
mWriteSet.reserve(128);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HashedObjectStore::tune(int size, int age)
|
||||||
|
{
|
||||||
|
mCache.setTargetSize(size);
|
||||||
|
mCache.setTargetAge(age);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool HashedObjectStore::store(HashedObjectType type, uint32 index,
|
bool HashedObjectStore::store(HashedObjectType type, uint32 index,
|
||||||
const std::vector<unsigned char>& data, const uint256& hash)
|
const std::vector<unsigned char>& data, const uint256& hash)
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public:
|
|||||||
|
|
||||||
void bulkWrite();
|
void bulkWrite();
|
||||||
void waitWrite();
|
void waitWrite();
|
||||||
|
void tune(int size, int age);
|
||||||
void sweep() { mCache.sweep(); mNegativeCache.sweep(); }
|
void sweep() { mCache.sweep(); mNegativeCache.sweep(); }
|
||||||
|
|
||||||
int import(const std::string&);
|
int import(const std::string&);
|
||||||
|
|||||||
@@ -115,4 +115,10 @@ Ledger::pointer LedgerHistory::canonicalizeLedger(Ledger::pointer ledger, bool s
|
|||||||
return ledger;
|
return ledger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LedgerHistory::tune(int size, int age)
|
||||||
|
{
|
||||||
|
mLedgersByHash.setTargetSize(size);
|
||||||
|
mLedgersByHash.setTargetAge(age);
|
||||||
|
}
|
||||||
|
|
||||||
// vim:ts=4
|
// vim:ts=4
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public:
|
|||||||
Ledger::pointer getLedgerBySeq(uint32 index);
|
Ledger::pointer getLedgerBySeq(uint32 index);
|
||||||
Ledger::pointer getLedgerByHash(const uint256& hash);
|
Ledger::pointer getLedgerByHash(const uint256& hash);
|
||||||
Ledger::pointer canonicalizeLedger(Ledger::pointer, bool cache);
|
Ledger::pointer canonicalizeLedger(Ledger::pointer, bool cache);
|
||||||
|
void tune(int size, int age);
|
||||||
void sweep() { mLedgersByHash.sweep(); }
|
void sweep() { mLedgersByHash.sweep(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -195,7 +195,8 @@ bool LedgerMaster::acquireMissingLedger(Ledger::ref origLedger, const uint256& l
|
|||||||
theApp->getIOService().post(boost::bind(&LedgerMaster::missingAcquireComplete, this, mMissingLedger));
|
theApp->getIOService().post(boost::bind(&LedgerMaster::missingAcquireComplete, this, mMissingLedger));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theApp->getMasterLedgerAcquire().getFetchCount() < 4)
|
int fetch = theConfig.getSize(siLedgerFetch);
|
||||||
|
if (theApp->getMasterLedgerAcquire().getFetchCount() < fetch)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
typedef std::pair<uint32, uint256> u_pair;
|
typedef std::pair<uint32, uint256> u_pair;
|
||||||
@@ -203,7 +204,7 @@ bool LedgerMaster::acquireMissingLedger(Ledger::ref origLedger, const uint256& l
|
|||||||
std::vector<u_pair> vec = origLedger->getLedgerHashes();
|
std::vector<u_pair> vec = origLedger->getLedgerHashes();
|
||||||
BOOST_REVERSE_FOREACH(const u_pair& it, vec)
|
BOOST_REVERSE_FOREACH(const u_pair& it, vec)
|
||||||
{
|
{
|
||||||
if ((count < 3) && (it.first < ledgerSeq) &&
|
if ((count < fetch) && (it.first < ledgerSeq) &&
|
||||||
!mCompleteLedgers.hasValue(it.first) && !theApp->getMasterLedgerAcquire().find(it.second))
|
!mCompleteLedgers.hasValue(it.first) && !theApp->getMasterLedgerAcquire().find(it.second))
|
||||||
{
|
{
|
||||||
++count;
|
++count;
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ public:
|
|||||||
|
|
||||||
void resumeAcquiring();
|
void resumeAcquiring();
|
||||||
|
|
||||||
|
void tune(int size, int age) { mLedgerHistory.tune(size, age); }
|
||||||
void sweep(void) { mLedgerHistory.sweep(); }
|
void sweep(void) { mLedgerHistory.sweep(); }
|
||||||
|
|
||||||
void addValidateCallback(callback& c) { mOnValidate.push_back(c); }
|
void addValidateCallback(callback& c) { mOnValidate.push_back(c); }
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ SETUP_LOG();
|
|||||||
typedef std::map<uint160, SerializedValidation::pointer>::value_type u160_val_pair;
|
typedef std::map<uint160, SerializedValidation::pointer>::value_type u160_val_pair;
|
||||||
typedef boost::shared_ptr<ValidationSet> VSpointer;
|
typedef boost::shared_ptr<ValidationSet> VSpointer;
|
||||||
|
|
||||||
|
void ValidationCollection::tune(int size, int age)
|
||||||
|
{
|
||||||
|
mValidations.setTargetSize(size);
|
||||||
|
mValidations.setTargetAge(age);
|
||||||
|
}
|
||||||
|
|
||||||
VSpointer ValidationCollection::findCreateSet(const uint256& ledgerHash)
|
VSpointer ValidationCollection::findCreateSet(const uint256& ledgerHash)
|
||||||
{
|
{
|
||||||
VSpointer j = mValidations.fetch(ledgerHash);
|
VSpointer j = mValidations.fetch(ledgerHash);
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
boost::unordered_map<uint256, currentValidationCount> getCurrentValidations(uint256 currentLedger);
|
boost::unordered_map<uint256, currentValidationCount> getCurrentValidations(uint256 currentLedger);
|
||||||
std::list<SerializedValidation::pointer> getCurrentTrustedValidations();
|
std::list<SerializedValidation::pointer> getCurrentTrustedValidations();
|
||||||
|
|
||||||
|
void tune(int size, int age);
|
||||||
void flush();
|
void flush();
|
||||||
void sweep() { mValidations.sweep(); }
|
void sweep() { mValidations.sweep(); }
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user