From 588ef7df8605c199edffc05fff6fb9f7b69c700a Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Thu, 16 May 2013 23:32:50 -0700 Subject: [PATCH 1/4] Speed up ledger acquiring. --- src/cpp/ripple/LedgerAcquire.cpp | 20 +++++++++++++++----- src/cpp/ripple/LedgerAcquire.h | 2 +- src/cpp/ripple/NetworkOPs.cpp | 2 +- src/cpp/ripple/SHAMap.cpp | 1 - src/cpp/ripple/SHAMapSync.cpp | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/cpp/ripple/LedgerAcquire.cpp b/src/cpp/ripple/LedgerAcquire.cpp index 291ff8f8f..5131c03cf 100644 --- a/src/cpp/ripple/LedgerAcquire.cpp +++ b/src/cpp/ripple/LedgerAcquire.cpp @@ -107,14 +107,17 @@ LedgerAcquire::LedgerAcquire(const uint256& hash, uint32 seq) : PeerSet(hash, LE tryLocal(); } -void LedgerAcquire::checkLocal() +bool LedgerAcquire::checkLocal() { boost::recursive_mutex::scoped_lock sl(mLock); if (isDone()) - return; + return false; - if (tryLocal()) - done(); + if (!tryLocal()) + return false; + + done(); + return true; } bool LedgerAcquire::tryLocal() @@ -1064,13 +1067,20 @@ void LedgerAcquireMaster::gotFetchPack(Job&) acquires.reserve(mLedgers.size()); typedef std::pair u256_acq_pair; BOOST_FOREACH(const u256_acq_pair& it, mLedgers) + { acquires.push_back(it.second); + } } + int completed = 0; BOOST_FOREACH(const LedgerAcquire::pointer& acquire, acquires) { - acquire->checkLocal(); + if (acquire->checkLocal()) + ++completed; } + + if (completed > 0) + theApp->getLedgerMaster().resumeAcquiring(); } // vim:ts=4 diff --git a/src/cpp/ripple/LedgerAcquire.h b/src/cpp/ripple/LedgerAcquire.h index 9e38b0062..7d69f493b 100644 --- a/src/cpp/ripple/LedgerAcquire.h +++ b/src/cpp/ripple/LedgerAcquire.h @@ -130,7 +130,7 @@ public: void addPeers(); void awaitData(); void noAwaitData(); - void checkLocal(); + bool checkLocal(); typedef std::pair neededHash_t; std::vector getNeededHashes(); diff --git a/src/cpp/ripple/NetworkOPs.cpp b/src/cpp/ripple/NetworkOPs.cpp index 4b09dde55..c56c11470 100644 --- a/src/cpp/ripple/NetworkOPs.cpp +++ b/src/cpp/ripple/NetworkOPs.cpp @@ -2121,7 +2121,7 @@ void NetworkOPs::gotFetchPack(bool progress, uint32 seq) mLastFetchPack = 0; mFetchSeq = seq; // earliest pack we have data on theApp->getJobQueue().addJob(jtLEDGER_DATA, "gotFetchPack", - boost::bind(&LedgerAcquireMaster::gotFetchPack, &theApp->getMasterLedgerAcquire(), _1)); + BIND_TYPE(&LedgerAcquireMaster::gotFetchPack, &theApp->getMasterLedgerAcquire(), P_1)); } void NetworkOPs::missingNodeInLedger(uint32 seq) diff --git a/src/cpp/ripple/SHAMap.cpp b/src/cpp/ripple/SHAMap.cpp index 7ac25fe96..834bdef6a 100644 --- a/src/cpp/ripple/SHAMap.cpp +++ b/src/cpp/ripple/SHAMap.cpp @@ -260,7 +260,6 @@ SHAMapTreeNode* SHAMap::getNodePointer(const SHAMapNode& id, const uint256& hash } } - void SHAMap::returnNode(SHAMapTreeNode::pointer& node, bool modify) { // make sure the node is suitable for the intended operation (copy on write) assert(node->isValid()); diff --git a/src/cpp/ripple/SHAMapSync.cpp b/src/cpp/ripple/SHAMapSync.cpp index eb14df863..35fa38f51 100644 --- a/src/cpp/ripple/SHAMapSync.cpp +++ b/src/cpp/ripple/SHAMapSync.cpp @@ -126,7 +126,7 @@ std::vector SHAMap::getNeededHashes(int max, SHAMapSyncFilter* filter) try { d = getNodePointer(childID, childHash, filter); - if (d->isInner() && !d->isFullBelow()) + if (d->isInner()) { have_all = false; stack.push(d); From e958a04abe2b49fa88f4efac76eb647e343c21c3 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Thu, 23 May 2013 20:19:05 -0700 Subject: [PATCH 2/4] Bump up the size of the ALCache. --- src/cpp/ripple/AcceptedLedger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpp/ripple/AcceptedLedger.cpp b/src/cpp/ripple/AcceptedLedger.cpp index 770d0e874..cb1bcf07a 100644 --- a/src/cpp/ripple/AcceptedLedger.cpp +++ b/src/cpp/ripple/AcceptedLedger.cpp @@ -2,7 +2,7 @@ #include -TaggedCache AcceptedLedger::ALCache("AcceptedLedger", 4, 60); +TaggedCache AcceptedLedger::ALCache("AcceptedLedger", 8, 120); ALTransaction::ALTransaction(uint32 seq, SerializerIterator& sit) { From 4af76c64ea3a60c1a02675315660326ab2ed2d60 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Fri, 24 May 2013 13:28:18 -0700 Subject: [PATCH 3/4] The deadlock detector was armed too early. --- src/cpp/ripple/Application.cpp | 1 + src/cpp/ripple/LoadManager.cpp | 6 +++--- src/cpp/ripple/LoadManager.h | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cpp/ripple/Application.cpp b/src/cpp/ripple/Application.cpp index 4c6cd9334..fcee58812 100644 --- a/src/cpp/ripple/Application.cpp +++ b/src/cpp/ripple/Application.cpp @@ -371,6 +371,7 @@ void Application::run() boost::thread(boost::bind(runIO, boost::ref(mIOService))).detach(); } + theApp->getLoadManager().arm(); mIOService.run(); // This blocks if (mWSPublicDoor) diff --git a/src/cpp/ripple/LoadManager.cpp b/src/cpp/ripple/LoadManager.cpp index 3f5fb662c..942ef7adc 100644 --- a/src/cpp/ripple/LoadManager.cpp +++ b/src/cpp/ripple/LoadManager.cpp @@ -22,7 +22,7 @@ int upTime() LoadManager::LoadManager(int creditRate, int creditLimit, int debitWarn, int debitLimit) : mCreditRate(creditRate), mCreditLimit(creditLimit), mDebitWarn(debitWarn), mDebitLimit(debitLimit), - mShutdown(false), mUptime(0), mDeadLock(0), mCosts(LT_MAX) + mShutdown(false), mArmed(false), mUptime(0), mDeadLock(0), mCosts(LT_MAX) { addLoadCost(LoadCost(LT_InvalidRequest, -10, LC_CPU | LC_Network)); addLoadCost(LoadCost(LT_RequestNoReply, -1, LC_CPU | LC_Disk)); @@ -353,14 +353,14 @@ void LoadManager::threadEntry() ++mUptime; int dlTime = mUptime - mDeadLock; - if (dlTime >= 10) + if (mArmed && (dlTime >= 10)) { if ((dlTime % 10) == 0) { boost::thread(BIND_TYPE(&LogDeadLock, dlTime)).detach(); } - assert (dlTime < 180); + assert (dlTime < 500); } } diff --git a/src/cpp/ripple/LoadManager.h b/src/cpp/ripple/LoadManager.h index 4257b21af..70944f8f2 100644 --- a/src/cpp/ripple/LoadManager.h +++ b/src/cpp/ripple/LoadManager.h @@ -101,6 +101,7 @@ protected: int mDebitLimit; // when a source drops below this, we cut it off (should be negative) bool mShutdown; + bool mArmed; int mSpace1[4]; // We want mUptime to have its own cache line int mUptime; @@ -144,6 +145,7 @@ public: int getCost(LoadType t) { return mCosts[static_cast(t)].mCost; } int getUptime(); void noDeadLock(); + void arm() { mArmed = true; } }; class LoadFeeTrack From aa52eac3905b6996a2a16d65cfc25696ac3cb037 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Sat, 25 May 2013 15:41:25 -0700 Subject: [PATCH 4/4] Make RPC proof_create admin only. --- src/cpp/ripple/RPCHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index a350ae65c..0d2d49279 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -3486,7 +3486,7 @@ Json::Value RPCHandler::doCommand(const Json::Value& jvRequest, int iRole, int & { "path_find", &RPCHandler::doPathFind, false, optCurrent }, { "ping", &RPCHandler::doPing, false, optNone }, // { "profile", &RPCHandler::doProfile, false, optCurrent }, - { "proof_create", &RPCHandler::doProofCreate, false, optNone }, + { "proof_create", &RPCHandler::doProofCreate, true, optNone }, { "proof_solve", &RPCHandler::doProofSolve, true, optNone }, { "proof_verify", &RPCHandler::doProofVerify, true, optNone }, { "random", &RPCHandler::doRandom, false, optNone },