From e48ef29f8c9ef7f0bde6beb78e521347fb4dbe76 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 28 Jan 2013 07:13:05 -0800 Subject: [PATCH] Dispatch HashedObject background writes through our job queue. --- src/cpp/ripple/HashedObject.cpp | 3 +-- src/cpp/ripple/JobQueue.cpp | 4 +++- src/cpp/ripple/JobQueue.h | 9 +++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/cpp/ripple/HashedObject.cpp b/src/cpp/ripple/HashedObject.cpp index 84e46da1e..44cfffbd4 100644 --- a/src/cpp/ripple/HashedObject.cpp +++ b/src/cpp/ripple/HashedObject.cpp @@ -51,7 +51,7 @@ bool HashedObjectStore::store(HashedObjectType type, uint32 index, if (!mWritePending) { mWritePending = true; - boost::thread(boost::bind(&HashedObjectStore::bulkWrite, this)).detach(); + theApp->getJobQueue().addJob(jtWRITE, boost::bind(&HashedObjectStore::bulkWrite, this)); } } // else @@ -70,7 +70,6 @@ void HashedObjectStore::waitWrite() void HashedObjectStore::bulkWrite() { - LoadEvent::autoptr event(theApp->getJobQueue().getLoadEventAP(jtDISK)); while (1) { std::vector< boost::shared_ptr > set; diff --git a/src/cpp/ripple/JobQueue.cpp b/src/cpp/ripple/JobQueue.cpp index 13d930ff7..fe1dcd829 100644 --- a/src/cpp/ripple/JobQueue.cpp +++ b/src/cpp/ripple/JobQueue.cpp @@ -17,6 +17,7 @@ JobQueue::JobQueue() : mLastJob(0), mThreadCount(0), mShuttingDown(false) mJobLoads[jtPROPOSAL_ut].setTargetLatency(500, 1250); mJobLoads[jtPUBLEDGER].setTargetLatency(1000, 2500); mJobLoads[jtVALIDATION_t].setTargetLatency(500, 1500); + mJobLoads[jtWRITE].setTargetLatency(750, 1500); mJobLoads[jtTRANSACTION_l].setTargetLatency(100, 500); mJobLoads[jtPROPOSAL_t].setTargetLatency(100, 500); @@ -40,6 +41,7 @@ const char* Job::toString(JobType t) case jtTRANSACTION: return "transaction"; case jtPUBLEDGER: return "publishLedger"; case jtVALIDATION_t: return "trustedValidation"; + case jtWRITE: return "writeObjects"; case jtTRANSACTION_l: return "localTransaction"; case jtPROPOSAL_t: return "trustedProposal"; case jtADMIN: return "administration"; @@ -196,7 +198,7 @@ void JobQueue::setThreadCount(int c) { c = boost::thread::hardware_concurrency(); if (c < 0) - c = 0; + c = 2; c += 2; cLog(lsINFO) << "Auto-tuning to " << c << " validation/transaction/proposal threads"; } diff --git a/src/cpp/ripple/JobQueue.h b/src/cpp/ripple/JobQueue.h index f45d2bb33..dfdcd1039 100644 --- a/src/cpp/ripple/JobQueue.h +++ b/src/cpp/ripple/JobQueue.h @@ -28,10 +28,11 @@ enum JobType jtTRANSACTION = 5, // A transaction received from the network jtPUBLEDGER = 6, // Publish a fully-accepted ledger jtVALIDATION_t = 7, // A validation from a trusted source - jtTRANSACTION_l = 8, // A local transaction - jtPROPOSAL_t = 9, // A proposal from a trusted source - jtADMIN = 10, // An administrative operation - jtDEATH = 11, // job of death, used internally + jtWRITE = 8, // Write out hashed objects + jtTRANSACTION_l = 9, // A local transaction + jtPROPOSAL_t = 10, // A proposal from a trusted source + jtADMIN = 11, // An administrative operation + jtDEATH = 12, // job of death, used internally // special types not dispatched by the job pool jtPEER = 17,