From 5ac22ff31b552e744b3792fafed8e31eab087fc4 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Tue, 20 Nov 2012 12:09:51 -0800 Subject: [PATCH] Two more load monitoring hooks. --- src/cpp/ripple/JobQueue.cpp | 1 + src/cpp/ripple/JobQueue.h | 1 + src/cpp/ripple/LedgerConsensus.cpp | 9 ++++++--- src/cpp/ripple/LedgerConsensus.h | 3 ++- src/cpp/ripple/TransactionMaster.cpp | 8 +++++++- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/cpp/ripple/JobQueue.cpp b/src/cpp/ripple/JobQueue.cpp index a72e8ddae0..dd730dcb6a 100644 --- a/src/cpp/ripple/JobQueue.cpp +++ b/src/cpp/ripple/JobQueue.cpp @@ -23,6 +23,7 @@ const char* Job::toString(JobType t) case jtCLIENT: return "clientCommand"; case jtPEER: return "peerCommand"; case jtDISK: return "diskAccess"; + case jtLEDGER: return "acceptLedger"; default: assert(false); return "unknown"; } } diff --git a/src/cpp/ripple/JobQueue.h b/src/cpp/ripple/JobQueue.h index 339804d206..1101cc2f75 100644 --- a/src/cpp/ripple/JobQueue.h +++ b/src/cpp/ripple/JobQueue.h @@ -36,6 +36,7 @@ enum JobType jtCLIENT = 10, jtPEER = 11, jtDISK = 12, + jtLEDGER = 13, }; #define NUM_JOB_TYPES 16 diff --git a/src/cpp/ripple/LedgerConsensus.cpp b/src/cpp/ripple/LedgerConsensus.cpp index 8daade3bdf..7cc01870db 100644 --- a/src/cpp/ripple/LedgerConsensus.cpp +++ b/src/cpp/ripple/LedgerConsensus.cpp @@ -1021,9 +1021,12 @@ void LedgerConsensus::beginAccept(bool synchronous) theApp->getOPs().newLCL(mPeerPositions.size(), mCurrentMSeconds, mNewLedgerHash); if (synchronous) - accept(consensusSet); + accept(consensusSet, LoadEvent::pointer()); else - theApp->getIOService().post(boost::bind(&LedgerConsensus::accept, shared_from_this(), consensusSet)); + { + theApp->getIOService().post(boost::bind(&LedgerConsensus::accept, shared_from_this(), consensusSet, + theApp->getJobQueue().getLoadEvent(jtLEDGER))); + } } void LedgerConsensus::playbackProposals() @@ -1170,7 +1173,7 @@ uint32 LedgerConsensus::roundCloseTime(uint32 closeTime) return closeTime - (closeTime % mCloseResolution); } -void LedgerConsensus::accept(SHAMap::ref set) +void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer) { boost::recursive_mutex::scoped_lock masterLock(theApp->getMasterLock()); assert(set->getHash() == mOurPosition->getCurrentHash()); diff --git a/src/cpp/ripple/LedgerConsensus.h b/src/cpp/ripple/LedgerConsensus.h index 3b66fa9f42..1db7069961 100644 --- a/src/cpp/ripple/LedgerConsensus.h +++ b/src/cpp/ripple/LedgerConsensus.h @@ -18,6 +18,7 @@ #include "CanonicalTXSet.h" #include "TransactionEngine.h" #include "InstanceCounter.h" +#include "LoadMonitor.h" DEFINE_INSTANCE(LedgerConsensus); @@ -120,7 +121,7 @@ protected: boost::unordered_set mDeadNodes; // final accept logic - void accept(SHAMap::ref txSet); + void accept(SHAMap::ref txSet, LoadEvent::pointer); void weHave(const uint256& id, Peer::ref avoidPeer); void startAcquiring(const TransactionAcquire::pointer&); diff --git a/src/cpp/ripple/TransactionMaster.cpp b/src/cpp/ripple/TransactionMaster.cpp index 196845bfdb..bfa0a8b720 100644 --- a/src/cpp/ripple/TransactionMaster.cpp +++ b/src/cpp/ripple/TransactionMaster.cpp @@ -53,13 +53,19 @@ SerializedTransaction::pointer TransactionMaster::fetch(SHAMapItem::ref item, bo return txn; } +static void saveTransactionHelper(Transaction::pointer txn, LoadEvent::pointer) +{ + Transaction::saveTransaction(txn); +} + bool TransactionMaster::canonicalize(Transaction::pointer& txn, bool may_be_new) { uint256 tid = txn->getID(); if (!tid) return false; if (mCache.canonicalize(tid, txn)) return true; if (may_be_new) - theApp->getAuxService().post(boost::bind(&Transaction::saveTransaction, txn)); + theApp->getAuxService().post(boost::bind(&saveTransactionHelper, txn, + theApp->getJobQueue().getLoadEvent(jtDISK))); return false; } // vim:ts=4