diff --git a/src/cpp/ripple/HashedObject.cpp b/src/cpp/ripple/HashedObject.cpp index 92f21172b9..5ff1733073 100644 --- a/src/cpp/ripple/HashedObject.cpp +++ b/src/cpp/ripple/HashedObject.cpp @@ -19,7 +19,7 @@ DECLARE_INSTANCE(HashedObject); HashedObjectStore::HashedObjectStore(int cacheSize, int cacheAge) : mCache("HashedObjectStore", cacheSize, cacheAge), mNegativeCache("HashedObjectNegativeCache", 0, 120), - mWriteGeneration(0), mWritePending(false), mLevelDB(false) + mWriteGeneration(0), mWriteLoad(0), mWritePending(false), mLevelDB(false) { mWriteSet.reserve(128); @@ -56,6 +56,12 @@ void HashedObjectStore::waitWrite() mWriteCondition.wait(sl); } +int HashedObjectStore::getWriteLoad() +{ + boost::mutex::scoped_lock sl(mWriteMutex); + return std::max(mWriteLoad, static_cast(mWriteSet.size())); +} + #ifdef USE_LEVELDB bool HashedObjectStore::storeLevelDB(HashedObjectType type, uint32 index, @@ -90,6 +96,7 @@ bool HashedObjectStore::storeLevelDB(HashedObjectType type, uint32 index, void HashedObjectStore::bulkWriteLevelDB() { assert(mLevelDB); + int setSize = 0; while (1) { std::vector< boost::shared_ptr > set; @@ -97,6 +104,7 @@ void HashedObjectStore::bulkWriteLevelDB() { boost::mutex::scoped_lock sl(mWriteMutex); + mWriteSet.swap(set); assert(mWriteSet.empty()); ++mWriteGeneration; @@ -104,8 +112,11 @@ void HashedObjectStore::bulkWriteLevelDB() if (set.empty()) { mWritePending = false; + mWriteLoad = 0; return; } + mWriteLoad = std::max(setSize, static_cast(mWriteSet.size())); + setSize = set.size(); } { diff --git a/src/cpp/ripple/HashedObject.h b/src/cpp/ripple/HashedObject.h index 014977ef5b..cfc712f131 100644 --- a/src/cpp/ripple/HashedObject.h +++ b/src/cpp/ripple/HashedObject.h @@ -55,6 +55,7 @@ protected: boost::mutex mWriteMutex; boost::condition_variable mWriteCondition; int mWriteGeneration; + int mWriteLoad; std::vector< boost::shared_ptr > mWriteSet; bool mWritePending; @@ -101,6 +102,7 @@ public: void waitWrite(); void tune(int size, int age); void sweep() { mCache.sweep(); mNegativeCache.sweep(); } + int getWriteLoad(); int import(const std::string& fileName); }; diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index aa185cfedc..de444d4dad 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -2317,6 +2317,8 @@ Json::Value RPCHandler::doGetCounts(Json::Value jvRequest, int& cost, ScopedLock if (dbKB > 0) ret["dbKBTransaction"] = dbKB; + ret["write_load"] = theApp->getHashedObjectStore().getWriteLoad(); + std::string uptime; int s = upTime(); textTime(uptime, s, "year", 365*24*60*60);