xrpld
Loading...
Searching...
No Matches
xrpl::perf::PerfLogImp Class Reference

Implementation class for PerfLog. More...

#include <PerfLogImp.h>

Inheritance diagram for xrpl::perf::PerfLogImp:
Collaboration diagram for xrpl::perf::PerfLogImp:

Classes

struct  Counters
 Track performance counters and currently executing tasks. More...

Public Types

using SteadyClock = std::chrono::steady_clock
using SystemClock = std::chrono::system_clock
using SteadyTimePoint = std::chrono::time_point<SteadyClock>
using SystemTimePoint = std::chrono::time_point<SystemClock>
using Seconds = std::chrono::seconds
using Milliseconds = std::chrono::milliseconds
using Microseconds = std::chrono::microseconds

Public Member Functions

 PerfLogImp (Setup setup, Application &app, std::span< NullTerminatedView const > methodNames, beast::Journal journal, std::function< void()> &&signalStop)
 ~PerfLogImp () override
void rpcStart (std::string_view method, std::uint64_t const requestId) override
 Log start of RPC call.
void rpcFinish (std::string_view method, std::uint64_t const requestId) override
 Log successful finish of RPC call.
void rpcError (std::string_view method, std::uint64_t const requestId) override
 Log errored RPC call.
void jobQueue (JobType const type) override
 Log queued job.
void jobStart (JobType const type, Microseconds dur, SteadyTimePoint startTime, int instance) override
 Log job executing.
void jobFinish (JobType const type, Microseconds dur, int instance) override
 Log job finishing.
json::Value countersJson () const override
 Render performance counters in Json.
json::Value currentJson () const override
 Render currently executing jobs and RPC calls and durations in Json.
void resizeJobs (int const resize) override
 Ensure enough room to store each currently executing job.
void rotate () override
 Rotate perf log file.
void start () override
void stop () override

Private Member Functions

void openLog ()
void run ()
void report ()
void rpcEnd (std::string_view method, std::uint64_t const requestId, bool finish)

Private Attributes

Setup const setup_
Application & app_
beast::Journal const j_
std::function< void()> const signalStop_
Counters counters_
std::ofstream logFile_
std::thread thread_
std::mutex mutex_
std::condition_variable cond_
SystemTimePoint lastLog_
std::string const hostname_ {boost::asio::ip::host_name()}
bool stop_ {false}
bool rotate_ {false}

Detailed Description

Implementation class for PerfLog.

Definition at line 54 of file PerfLogImp.h.

Member Typedef Documentation

◆ SteadyClock

Definition at line 35 of file PerfLog.h.

◆ SystemClock

Definition at line 36 of file PerfLog.h.

◆ SteadyTimePoint

◆ SystemTimePoint

◆ Seconds

Definition at line 39 of file PerfLog.h.

◆ Milliseconds

Definition at line 40 of file PerfLog.h.

◆ Microseconds

Definition at line 41 of file PerfLog.h.

Constructor & Destructor Documentation

◆ PerfLogImp()

xrpl::perf::PerfLogImp::PerfLogImp ( Setup setup,
Application & app,
std::span< NullTerminatedView const > methodNames,
beast::Journal journal,
std::function< void()> && signalStop )
Parameters
methodNamesThe RPC methods to count, one counter per name. The names must outlive this object, which holds views of them. Passed in rather than looked up here so that this layer needs to know nothing about the RPC dispatch table.

Definition at line 317 of file PerfLogImp.cpp.

◆ ~PerfLogImp()

xrpl::perf::PerfLogImp::~PerfLogImp ( )
override

Definition at line 332 of file PerfLogImp.cpp.

Member Function Documentation

◆ openLog()

void xrpl::perf::PerfLogImp::openLog ( )
private

Definition at line 231 of file PerfLogImp.cpp.

◆ run()

void xrpl::perf::PerfLogImp::run ( )
private

Definition at line 264 of file PerfLogImp.cpp.

◆ report()

void xrpl::perf::PerfLogImp::report ( )
private

Definition at line 288 of file PerfLogImp.cpp.

◆ rpcEnd()

void xrpl::perf::PerfLogImp::rpcEnd ( std::string_view method,
std::uint64_t const requestId,
bool finish )
private

Definition at line 359 of file PerfLogImp.cpp.

◆ rpcStart()

void xrpl::perf::PerfLogImp::rpcStart ( std::string_view method,
std::uint64_t const requestId )
overridevirtual

Log start of RPC call.

Parameters
methodRPC command
requestIdUnique identifier to track command

Implements xrpl::perf::PerfLog.

Definition at line 338 of file PerfLogImp.cpp.

◆ rpcFinish()

void xrpl::perf::PerfLogImp::rpcFinish ( std::string_view method,
std::uint64_t const requestId )
overridevirtual

Log successful finish of RPC call.

Parameters
methodRPC command
requestIdUnique identifier to track command

Implements xrpl::perf::PerfLog.

Definition at line 165 of file PerfLogImp.h.

◆ rpcError()

void xrpl::perf::PerfLogImp::rpcError ( std::string_view method,
std::uint64_t const requestId )
overridevirtual

Log errored RPC call.

Parameters
methodRPC command
requestIdUnique identifier to track command

Implements xrpl::perf::PerfLog.

Definition at line 171 of file PerfLogImp.h.

◆ jobQueue()

void xrpl::perf::PerfLogImp::jobQueue ( JobType const type)
overridevirtual

Log queued job.

Parameters
typeJob type

Implements xrpl::perf::PerfLog.

Definition at line 399 of file PerfLogImp.cpp.

◆ jobStart()

void xrpl::perf::PerfLogImp::jobStart ( JobType const type,
Microseconds dur,
SteadyTimePoint startTime,
int instance )
overridevirtual

Log job executing.

Parameters
typeJob type
durDuration enqueued in microseconds
startTimeTime that execution began
instanceJobQueue worker thread instance

Implements xrpl::perf::PerfLog.

Definition at line 414 of file PerfLogImp.cpp.

◆ jobFinish()

void xrpl::perf::PerfLogImp::jobFinish ( JobType const type,
Microseconds dur,
int instance )
overridevirtual

Log job finishing.

Parameters
typeJob type
durDuration running in microseconds
instanceJobqueue worker thread instance

Implements xrpl::perf::PerfLog.

Definition at line 436 of file PerfLogImp.cpp.

◆ countersJson()

json::Value xrpl::perf::PerfLogImp::countersJson ( ) const
overridevirtual

Render performance counters in Json.

Returns
Counters Json object

Implements xrpl::perf::PerfLog.

Definition at line 185 of file PerfLogImp.h.

◆ currentJson()

json::Value xrpl::perf::PerfLogImp::currentJson ( ) const
overridevirtual

Render currently executing jobs and RPC calls and durations in Json.

Returns
Current executing jobs and RPC calls and durations

Implements xrpl::perf::PerfLog.

Definition at line 191 of file PerfLogImp.h.

◆ resizeJobs()

void xrpl::perf::PerfLogImp::resizeJobs ( int const resize)
overridevirtual

Ensure enough room to store each currently executing job.

Parameters
resizeNumber of JobQueue worker threads

Implements xrpl::perf::PerfLog.

Definition at line 458 of file PerfLogImp.cpp.

◆ rotate()

void xrpl::perf::PerfLogImp::rotate ( )
overridevirtual

Rotate perf log file.

Implements xrpl::perf::PerfLog.

Definition at line 466 of file PerfLogImp.cpp.

◆ start()

void xrpl::perf::PerfLogImp::start ( )
overridevirtual

Reimplemented from xrpl::perf::PerfLog.

Definition at line 477 of file PerfLogImp.cpp.

◆ stop()

void xrpl::perf::PerfLogImp::stop ( )
overridevirtual

Reimplemented from xrpl::perf::PerfLog.

Definition at line 484 of file PerfLogImp.cpp.

Member Data Documentation

◆ setup_

Setup const xrpl::perf::PerfLogImp::setup_
private

Definition at line 122 of file PerfLogImp.h.

◆ app_

Application& xrpl::perf::PerfLogImp::app_
private

Definition at line 123 of file PerfLogImp.h.

◆ j_

beast::Journal const xrpl::perf::PerfLogImp::j_
private

Definition at line 124 of file PerfLogImp.h.

◆ signalStop_

std::function<void()> const xrpl::perf::PerfLogImp::signalStop_
private

Definition at line 125 of file PerfLogImp.h.

◆ counters_

Counters xrpl::perf::PerfLogImp::counters_
private

Definition at line 126 of file PerfLogImp.h.

◆ logFile_

std::ofstream xrpl::perf::PerfLogImp::logFile_
private

Definition at line 127 of file PerfLogImp.h.

◆ thread_

std::thread xrpl::perf::PerfLogImp::thread_
private

Definition at line 128 of file PerfLogImp.h.

◆ mutex_

std::mutex xrpl::perf::PerfLogImp::mutex_
private

Definition at line 129 of file PerfLogImp.h.

◆ cond_

std::condition_variable xrpl::perf::PerfLogImp::cond_
private

Definition at line 130 of file PerfLogImp.h.

◆ lastLog_

SystemTimePoint xrpl::perf::PerfLogImp::lastLog_
private

Definition at line 131 of file PerfLogImp.h.

◆ hostname_

std::string const xrpl::perf::PerfLogImp::hostname_ {boost::asio::ip::host_name()}
private

Definition at line 132 of file PerfLogImp.h.

◆ stop_

bool xrpl::perf::PerfLogImp::stop_ {false}
private

Definition at line 133 of file PerfLogImp.h.

◆ rotate_

bool xrpl::perf::PerfLogImp::rotate_ {false}
private

Definition at line 134 of file PerfLogImp.h.