mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 14:35:52 +00:00
Rework the way load is accounted to be more accurate and more specific.
This commit is contained in:
@@ -223,7 +223,7 @@ void SqliteDatabase::doHook(const char *db, int pages)
|
|||||||
{
|
{
|
||||||
walRunning = true;
|
walRunning = true;
|
||||||
if (mWalQ)
|
if (mWalQ)
|
||||||
mWalQ->addJob(jtWAL, boost::bind(&SqliteDatabase::runWal, this));
|
mWalQ->addJob(jtWAL, std::string("WAL:") + db, boost::bind(&SqliteDatabase::runWal, this));
|
||||||
else
|
else
|
||||||
boost::thread(boost::bind(&SqliteDatabase::runWal, this)).detach();
|
boost::thread(boost::bind(&SqliteDatabase::runWal, this)).detach();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ bool HashedObjectStore::store(HashedObjectType type, uint32 index,
|
|||||||
if (!mWritePending)
|
if (!mWritePending)
|
||||||
{
|
{
|
||||||
mWritePending = true;
|
mWritePending = true;
|
||||||
theApp->getJobQueue().addJob(jtWRITE, boost::bind(&HashedObjectStore::bulkWrite, this));
|
theApp->getJobQueue().addJob(jtWRITE, "HasedObject::store",
|
||||||
|
boost::bind(&HashedObjectStore::bulkWrite, this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else
|
// else
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ bool Job::operator<=(const Job& j) const
|
|||||||
return mJobIndex <= j.mJobIndex;
|
return mJobIndex <= j.mJobIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JobQueue::addJob(JobType type, const boost::function<void(Job&)>& jobFunc)
|
void JobQueue::addJob(JobType type, const std::string& name, const boost::function<void(Job&)>& jobFunc)
|
||||||
{
|
{
|
||||||
assert(type != jtINVALID);
|
assert(type != jtINVALID);
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ void JobQueue::addJob(JobType type, const boost::function<void(Job&)>& jobFunc)
|
|||||||
if (type != jtCLIENT) // FIXME: Workaround incorrect client shutdown ordering
|
if (type != jtCLIENT) // FIXME: Workaround incorrect client shutdown ordering
|
||||||
assert(mThreadCount != 0); // do not add jobs to a queue with no threads
|
assert(mThreadCount != 0); // do not add jobs to a queue with no threads
|
||||||
|
|
||||||
mJobSet.insert(Job(type, ++mLastJob, mJobLoads[type], jobFunc));
|
mJobSet.insert(Job(type, name, ++mLastJob, mJobLoads[type], jobFunc));
|
||||||
++mJobCounts[type];
|
++mJobCounts[type];
|
||||||
mJobCond.notify_one();
|
mJobCond.notify_one();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ protected:
|
|||||||
uint64 mJobIndex;
|
uint64 mJobIndex;
|
||||||
boost::function<void(Job&)> mJob;
|
boost::function<void(Job&)> mJob;
|
||||||
LoadEvent::pointer mLoadMonitor;
|
LoadEvent::pointer mLoadMonitor;
|
||||||
|
std::string mName;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -62,12 +63,15 @@ public:
|
|||||||
Job(JobType type, uint64 index) : mType(type), mJobIndex(index)
|
Job(JobType type, uint64 index) : mType(type), mJobIndex(index)
|
||||||
{ ; }
|
{ ; }
|
||||||
|
|
||||||
Job(JobType type, uint64 index, LoadMonitor& lm, const boost::function<void(Job&)>& job)
|
Job(JobType type, const std::string& name, uint64 index, LoadMonitor& lm, const boost::function<void(Job&)>& job)
|
||||||
: mType(type), mJobIndex(index), mJob(job)
|
: mType(type), mJobIndex(index), mJob(job), mName(name)
|
||||||
{ mLoadMonitor = boost::make_shared<LoadEvent>(boost::ref(lm), true, 1); }
|
{
|
||||||
|
mLoadMonitor = boost::make_shared<LoadEvent>(boost::ref(lm), false, 1);
|
||||||
|
}
|
||||||
|
|
||||||
JobType getType() const { return mType; }
|
JobType getType() const { return mType; }
|
||||||
void doJob(void) { mJob(*this); }
|
void doJob(void) { mLoadMonitor->start(); mJob(*this); mLoadMonitor->setName(mName); }
|
||||||
|
void rename(const std::string& n) { mName = n; }
|
||||||
|
|
||||||
bool operator<(const Job& j) const;
|
bool operator<(const Job& j) const;
|
||||||
bool operator>(const Job& j) const;
|
bool operator>(const Job& j) const;
|
||||||
@@ -97,7 +101,7 @@ public:
|
|||||||
|
|
||||||
JobQueue();
|
JobQueue();
|
||||||
|
|
||||||
void addJob(JobType type, const boost::function<void(Job&)>& job);
|
void addJob(JobType type, const std::string& name, const boost::function<void(Job&)>& job);
|
||||||
|
|
||||||
int getJobCount(JobType t); // Jobs at this priority
|
int getJobCount(JobType t); // Jobs at this priority
|
||||||
int getJobCountGE(JobType t); // All jobs at or greater than this priority
|
int getJobCountGE(JobType t); // All jobs at or greater than this priority
|
||||||
|
|||||||
@@ -186,7 +186,8 @@ bool LedgerMaster::acquireMissingLedger(Ledger::ref origLedger, const uint256& l
|
|||||||
{
|
{
|
||||||
cLog(lsTRACE) << "Ledger hash found in database";
|
cLog(lsTRACE) << "Ledger hash found in database";
|
||||||
mTooFast = true;
|
mTooFast = true;
|
||||||
theApp->getJobQueue().addJob(jtPUBOLDLEDGER, boost::bind(&LedgerMaster::asyncAccept, this, ledger));
|
theApp->getJobQueue().addJob(jtPUBOLDLEDGER, "LedgerMaster::asyncAccept",
|
||||||
|
boost::bind(&LedgerMaster::asyncAccept, this, ledger));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,7 +541,8 @@ void LedgerMaster::tryPublish()
|
|||||||
{
|
{
|
||||||
theApp->getOPs().clearNeedNetworkLedger();
|
theApp->getOPs().clearNeedNetworkLedger();
|
||||||
mPubThread = true;
|
mPubThread = true;
|
||||||
theApp->getJobQueue().addJob(jtPUBLEDGER, boost::bind(&LedgerMaster::pubThread, this));
|
theApp->getJobQueue().addJob(jtPUBLEDGER, "Ledger::pubThread",
|
||||||
|
boost::bind(&LedgerMaster::pubThread, this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -318,7 +318,10 @@ void LoadManager::threadEntry()
|
|||||||
|
|
||||||
bool change;
|
bool change;
|
||||||
if (theApp->getJobQueue().isOverloaded())
|
if (theApp->getJobQueue().isOverloaded())
|
||||||
|
{
|
||||||
|
cLog(lsINFO) << theApp->getJobQueue().getJson(0);
|
||||||
change = theApp->getFeeTrack().raiseLocalFee();
|
change = theApp->getFeeTrack().raiseLocalFee();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
change = theApp->getFeeTrack().lowerLocalFee();
|
change = theApp->getFeeTrack().lowerLocalFee();
|
||||||
if (change)
|
if (change)
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
#include "LoadMonitor.h"
|
#include "LoadMonitor.h"
|
||||||
|
#include "Log.h"
|
||||||
|
|
||||||
|
SETUP_LOG();
|
||||||
|
|
||||||
void LoadMonitor::update()
|
void LoadMonitor::update()
|
||||||
{ // call with the mutex
|
{ // call with the mutex
|
||||||
@@ -52,8 +55,10 @@ void LoadMonitor::addLatency(int latency)
|
|||||||
mLatencyMSPeak = lp;
|
mLatencyMSPeak = lp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadMonitor::addCountAndLatency(int counts, int latency)
|
void LoadMonitor::addCountAndLatency(const std::string& name, int counts, int latency)
|
||||||
{
|
{
|
||||||
|
if (latency > 1000)
|
||||||
|
cLog(lsWARNING) << "Job: " << name << " Latency: " << latency;
|
||||||
if (latency == 1)
|
if (latency == 1)
|
||||||
latency = 0;
|
latency = 0;
|
||||||
boost::mutex::scoped_lock sl(mLock);
|
boost::mutex::scoped_lock sl(mLock);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public:
|
|||||||
|
|
||||||
void addCount(int counts);
|
void addCount(int counts);
|
||||||
void addLatency(int latency);
|
void addLatency(int latency);
|
||||||
void addCountAndLatency(int counts, int latency);
|
void addCountAndLatency(const std::string& name, int counts, int latency);
|
||||||
|
|
||||||
void setTargetLatency(uint64 avg, uint64 pk)
|
void setTargetLatency(uint64 avg, uint64 pk)
|
||||||
{
|
{
|
||||||
@@ -60,6 +60,7 @@ protected:
|
|||||||
LoadMonitor& mMonitor;
|
LoadMonitor& mMonitor;
|
||||||
bool mRunning;
|
bool mRunning;
|
||||||
int mCount;
|
int mCount;
|
||||||
|
std::string mName;
|
||||||
boost::posix_time::ptime mStartTime;
|
boost::posix_time::ptime mStartTime;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -76,6 +77,11 @@ public:
|
|||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setName(const std::string& name)
|
||||||
|
{
|
||||||
|
mName = name;
|
||||||
|
}
|
||||||
|
|
||||||
void start()
|
void start()
|
||||||
{ // okay to call if already started
|
{ // okay to call if already started
|
||||||
mRunning = true;
|
mRunning = true;
|
||||||
@@ -86,7 +92,7 @@ public:
|
|||||||
{
|
{
|
||||||
assert(mRunning);
|
assert(mRunning);
|
||||||
mRunning = false;
|
mRunning = false;
|
||||||
mMonitor.addCountAndLatency(mCount,
|
mMonitor.addCountAndLatency(mName, mCount,
|
||||||
static_cast<int>((boost::posix_time::microsec_clock::universal_time() - mStartTime).total_milliseconds()));
|
static_cast<int>((boost::posix_time::microsec_clock::universal_time() - mStartTime).total_milliseconds()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1377,7 +1377,7 @@ void NetworkOPs::reportFeeChange()
|
|||||||
(theApp->getFeeTrack().getLoadFactor() == mLastLoadFactor))
|
(theApp->getFeeTrack().getLoadFactor() == mLastLoadFactor))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
theApp->getJobQueue().addJob(jtCLIENT, boost::bind(&NetworkOPs::pubServer, this));
|
theApp->getJobQueue().addJob(jtCLIENT, "reportFeeChange->pubServer", boost::bind(&NetworkOPs::pubServer, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Value NetworkOPs::transJson(const SerializedTransaction& stTxn, TER terResult, bool bAccepted, Ledger::ref lpCurrent, const std::string& strType)
|
Json::Value NetworkOPs::transJson(const SerializedTransaction& stTxn, TER terResult, bool bAccepted, Ledger::ref lpCurrent, const std::string& strType)
|
||||||
|
|||||||
@@ -857,7 +857,7 @@ void Peer::recvTransaction(ripple::TMTransaction& packet)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
theApp->getJobQueue().addJob(jtTRANSACTION,
|
theApp->getJobQueue().addJob(jtTRANSACTION, "recvTransction->checkTransaction",
|
||||||
boost::bind(&checkTransaction, _1, flags, stx, boost::weak_ptr<Peer>(shared_from_this())));
|
boost::bind(&checkTransaction, _1, flags, stx, boost::weak_ptr<Peer>(shared_from_this())));
|
||||||
|
|
||||||
#ifndef TRUST_NETWORK
|
#ifndef TRUST_NETWORK
|
||||||
@@ -986,7 +986,7 @@ void Peer::recvPropose(const boost::shared_ptr<ripple::TMProposeSet>& packet)
|
|||||||
prevLedger.isNonZero() ? prevLedger : consensusLCL,
|
prevLedger.isNonZero() ? prevLedger : consensusLCL,
|
||||||
set.proposeseq(), proposeHash, set.closetime(), signerPublic, suppression);
|
set.proposeseq(), proposeHash, set.closetime(), signerPublic, suppression);
|
||||||
|
|
||||||
theApp->getJobQueue().addJob(isTrusted ? jtPROPOSAL_t : jtPROPOSAL_ut,
|
theApp->getJobQueue().addJob(isTrusted ? jtPROPOSAL_t : jtPROPOSAL_ut, "recvPropose->checkPropose",
|
||||||
boost::bind(&checkPropose, _1, packet, proposal, consensusLCL,
|
boost::bind(&checkPropose, _1, packet, proposal, consensusLCL,
|
||||||
mNodePublic, boost::weak_ptr<Peer>(shared_from_this())));
|
mNodePublic, boost::weak_ptr<Peer>(shared_from_this())));
|
||||||
}
|
}
|
||||||
@@ -1062,7 +1062,7 @@ void Peer::recvValidation(const boost::shared_ptr<ripple::TMValidation>& packet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isTrusted = theApp->getUNL().nodeInUNL(val->getSignerPublic());
|
bool isTrusted = theApp->getUNL().nodeInUNL(val->getSignerPublic());
|
||||||
theApp->getJobQueue().addJob(isTrusted ? jtVALIDATION_t : jtVALIDATION_ut,
|
theApp->getJobQueue().addJob(isTrusted ? jtVALIDATION_t : jtVALIDATION_ut, "recvValidation->checkValidation",
|
||||||
boost::bind(&checkValidation, _1, val, signingHash, isTrusted, packet,
|
boost::bind(&checkValidation, _1, val, signingHash, isTrusted, packet,
|
||||||
boost::weak_ptr<Peer>(shared_from_this())));
|
boost::weak_ptr<Peer>(shared_from_this())));
|
||||||
}
|
}
|
||||||
@@ -1299,7 +1299,7 @@ void Peer::recvProofWork(ripple::TMProofWork& packet)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
theApp->getJobQueue().addJob(jtPROOFWORK,
|
theApp->getJobQueue().addJob(jtPROOFWORK, "recvProof->doProof",
|
||||||
boost::bind(&Peer::doProofOfWork, _1, boost::weak_ptr<Peer>(shared_from_this()), pow));
|
boost::bind(&Peer::doProofOfWork, _1, boost::weak_ptr<Peer>(shared_from_this()), pow));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -293,7 +293,8 @@ void ValidationCollection::condWrite()
|
|||||||
if (mWriting)
|
if (mWriting)
|
||||||
return;
|
return;
|
||||||
mWriting = true;
|
mWriting = true;
|
||||||
theApp->getJobQueue().addJob(jtWRITE, boost::bind(&ValidationCollection::doWrite, this, _1));
|
theApp->getJobQueue().addJob(jtWRITE, "ValidationCollection::doWrite",
|
||||||
|
boost::bind(&ValidationCollection::doWrite, this, _1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValidationCollection::doWrite(Job&)
|
void ValidationCollection::doWrite(Job&)
|
||||||
|
|||||||
@@ -152,17 +152,17 @@ public:
|
|||||||
ptr->preDestroy(); // Must be done before we return
|
ptr->preDestroy(); // Must be done before we return
|
||||||
|
|
||||||
// Must be done without holding the websocket send lock
|
// Must be done without holding the websocket send lock
|
||||||
theApp->getJobQueue().addJob(jtCLIENT,
|
theApp->getJobQueue().addJob(jtCLIENT, "WSClient::destroy",
|
||||||
boost::bind(&WSConnection<endpoint_type>::destroy, ptr));
|
boost::bind(&WSConnection<endpoint_type>::destroy, ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_message(connection_ptr cpClient, message_ptr mpMessage)
|
void on_message(connection_ptr cpClient, message_ptr mpMessage)
|
||||||
{
|
{
|
||||||
theApp->getJobQueue().addJob(jtCLIENT,
|
theApp->getJobQueue().addJob(jtCLIENT, "WSClient::command",
|
||||||
boost::bind(&WSServerHandler<endpoint_type>::do_message, this, _1, cpClient, mpMessage));
|
boost::bind(&WSServerHandler<endpoint_type>::do_message, this, _1, cpClient, mpMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_message(Job&, connection_ptr cpClient, message_ptr mpMessage)
|
void do_message(Job& job, connection_ptr cpClient, message_ptr mpMessage)
|
||||||
{
|
{
|
||||||
Json::Value jvRequest;
|
Json::Value jvRequest;
|
||||||
Json::Reader jrReader;
|
Json::Reader jrReader;
|
||||||
@@ -190,6 +190,8 @@ public:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (jvRequest.isMember("command"))
|
||||||
|
job.rename(std::string("WSClient::") + jvRequest["command"].asString());
|
||||||
boost::shared_ptr< WSConnection<endpoint_type> > conn;
|
boost::shared_ptr< WSConnection<endpoint_type> > conn;
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock sl(mMapLock);
|
boost::mutex::scoped_lock sl(mMapLock);
|
||||||
|
|||||||
Reference in New Issue
Block a user