Performance logging and counters:

* Tally and duration counters for Job Queue tasks and RPC calls
    optionally rendered by server_info and server_state, and
    optionally printed to a distinct log file.
    - Tally each Job Queue task as it is queued, starts, and
      finishes running. Track total duration queued and running.
    - Tally each RPC call as it starts and either finishes
      successfully or throws an exception. Track total running
      duration for each.
  * Track currently executing Job Queue tasks and RPC methods
    along with durations.
  * Json-formatted performance log file written by a dedicated
    thread, for above-described data.
  * New optional parameter, "counters", for server_info and
    server_state. If set, render Job Queue and RPC call counters
    as well as currently executing tasks.
  * New configuration section, "[perf]", to optionally control
    performance logging to a file.
  * Support optional sub-second periods when rendering human-readable
    time points.
This commit is contained in:
Mark Travis
2018-01-13 04:02:43 -08:00
committed by Nikolaos D. Bougalis
parent ef3bc92b82
commit 8eb8c77886
45 changed files with 10379 additions and 577 deletions

View File

@@ -19,9 +19,66 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <ripple/core/impl/Workers.h>
#include <ripple/beast/unit_test.h>
#include <ripple/basics/PerfLog.h>
#include <ripple/core/JobTypes.h>
#include <ripple/json/json_value.h>
#include <chrono>
#include <cstdint>
#include <memory>
#include <string>
namespace ripple {
/**
* Dummy class for unit tests.
*/
namespace perf {
class PerfLogTest
: public PerfLog
{
void rpcStart(std::string const &method, std::uint64_t requestId) override
{}
void rpcFinish(std::string const &method, std::uint64_t requestId) override
{}
void rpcError(std::string const &method, std::uint64_t dur) override
{}
void jobQueue(JobType const type) override
{}
void jobStart(JobType const type,
std::chrono::microseconds dur,
std::chrono::time_point<std::chrono::steady_clock> startTime,
int instance) override
{}
void jobFinish(JobType const type, std::chrono::microseconds dur,
int instance) override
{}
Json::Value countersJson() const override
{
return Json::Value();
}
Json::Value currentJson() const override
{
return Json::Value();
}
void resizeJobs(int const resize) override
{}
void rotate() override
{}
};
} // perf
//------------------------------------------------------------------------------
class Workers_test : public beast::unit_test::suite
@@ -35,7 +92,7 @@ public:
{
}
void processTask()
void processTask(int instance) override
{
if (--count == 0)
finished.signal();
@@ -51,8 +108,10 @@ public:
" -> " + std::to_string(tc2) + " -> " + std::to_string(tc3));
TestCallback cb;
std::unique_ptr<perf::PerfLog> perfLog =
std::make_unique<perf::PerfLogTest>();
Workers w(cb, "Test", tc1);
Workers w(cb, *perfLog, "Test", tc1);
BEAST_EXPECT(w.getNumberOfThreads() == tc1);
auto testForThreadCount = [this, &cb, &w] (int const threadCount)