measureDurationAndLog wip 1

This commit is contained in:
Valentin Balaschenko
2025-05-22 17:29:56 +01:00
parent fbda5ccc15
commit 8a5f95c223
4 changed files with 77 additions and 31 deletions

View File

@@ -24,10 +24,13 @@
#include <xrpld/app/misc/NetworkOPs.h>
#include <xrpld/core/Config.h>
#include <xrpld/core/JobQueue.h>
#include <xrpld/perflog/PerfLog.h>
#include <xrpl/basics/Log.h>
#include <xrpl/protocol/Indexes.h>
using namespace std::chrono_literals;
namespace ripple {
OrderBookDB::OrderBookDB(Application& app)
@@ -69,7 +72,13 @@ OrderBookDB::setup(std::shared_ptr<ReadView const> const& ledger)
app_.getJobQueue().addJob(
jtUPDATE_PF,
"OrderBookDB::update: " + std::to_string(ledger->seq()),
[this, ledger]() { update(ledger); });
[this, ledger, journal = j_]() {
perf::measureDurationAndLog(
[&]() { update(ledger); },
"OrderBookDB::update:",
1s,
journal);
});
}
}

View File

@@ -25,6 +25,7 @@
#include <xrpld/app/main/Application.h>
#include <xrpld/core/JobQueue.h>
#include <xrpld/overlay/Overlay.h>
#include <xrpld/perflog/PerfLog.h>
#include <xrpld/shamap/SHAMapNodeID.h>
#include <xrpl/basics/Log.h>
@@ -37,6 +38,8 @@
#include <algorithm>
#include <random>
using namespace std::chrono_literals;
namespace ripple {
using namespace std::chrono_literals;
@@ -473,15 +476,24 @@ InboundLedger::done()
// We hold the PeerSet lock, so must dispatch
app_.getJobQueue().addJob(
jtLEDGER_DATA, "AcquisitionDone", [self = shared_from_this()]() {
if (self->complete_ && !self->failed_)
{
self->app_.getLedgerMaster().checkAccept(self->getLedger());
self->app_.getLedgerMaster().tryAdvance();
}
else
self->app_.getInboundLedgers().logFailure(
self->hash_, self->mSeq);
jtLEDGER_DATA,
"AcquisitionDone",
[self = shared_from_this(), journal = journal_]() {
perf::measureDurationAndLog(
[&]() {
if (self->complete_ && !self->failed_)
{
self->app_.getLedgerMaster().checkAccept(
self->getLedger());
self->app_.getLedgerMaster().tryAdvance();
}
else
self->app_.getInboundLedgers().logFailure(
self->hash_, self->mSeq);
},
"AcquisitionDone",
1s,
journal);
});
}
@@ -1026,8 +1038,9 @@ InboundLedger::getNeededHashes()
mLedger->txMap().family().db(), app_.getLedgerMaster());
for (auto const& h : neededTxHashes(4, &filter))
{
ret.push_back(std::make_pair(
protocol::TMGetObjectByHash::otTRANSACTION_NODE, h));
ret.push_back(
std::make_pair(
protocol::TMGetObjectByHash::otTRANSACTION_NODE, h));
}
}

View File

@@ -35,6 +35,8 @@
#include <mutex>
#include <vector>
using namespace std::chrono_literals;
namespace ripple {
class InboundLedgersImp : public InboundLedgers
@@ -212,8 +214,14 @@ public:
// dispatch
if (ledger->gotData(std::weak_ptr<Peer>(peer), packet))
app_.getJobQueue().addJob(
jtLEDGER_DATA, "processLedgerData", [ledger]() {
ledger->runData();
jtLEDGER_DATA,
"processLedgerData",
[ledger, journal = j_]() {
perf::measureDurationAndLog(
[&]() { ledger->runData(); },
"processLedgerData",
1s,
journal);
});
return true;
@@ -227,8 +235,12 @@ public:
if (packet->type() == protocol::liAS_NODE)
{
app_.getJobQueue().addJob(
jtLEDGER_DATA, "gotStaleData", [this, packet]() {
gotStaleData(packet);
jtLEDGER_DATA, "gotStaleData", [this, packet, journal = j_]() {
perf::measureDurationAndLog(
[&]() { gotStaleData(packet); },
"gotStaleData",
1s,
journal);
});
}

View File

@@ -25,6 +25,9 @@
#include <xrpld/app/main/Application.h>
#include <xrpld/core/JobQueue.h>
#include <xrpld/overlay/PeerSet.h>
#include <xrpld/perflog/PerfLog.h>
using namespace std::chrono_literals;
namespace ripple {
@@ -244,22 +247,31 @@ LedgerDeltaAcquire::onLedgerBuilt(
app_.getJobQueue().addJob(
jtREPLAY_TASK,
"onLedgerBuilt",
[=, ledger = this->fullLedger_, &app = this->app_]() {
for (auto reason : reasons)
{
switch (reason)
{
case InboundLedger::Reason::GENERIC:
app.getLedgerMaster().storeLedger(ledger);
break;
default:
// TODO for other use cases
break;
}
}
[=,
ledger = this->fullLedger_,
&app = this->app_,
journal = journal_]() {
perf::measureDurationAndLog(
[&]() {
for (auto reason : reasons)
{
switch (reason)
{
case InboundLedger::Reason::GENERIC:
app.getLedgerMaster().storeLedger(ledger);
break;
default:
// TODO for other use cases
break;
}
}
if (firstTime)
app.getLedgerMaster().tryAdvance();
if (firstTime)
app.getLedgerMaster().tryAdvance();
},
"onLedgerBuilt",
1s,
journal);
});
}