Skip to content

Commit

Permalink
Add metrics reporting to diagnostics.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Feb 3, 2018
1 parent 612a468 commit c8bb677
Show file tree
Hide file tree
Showing 13 changed files with 375 additions and 116 deletions.
6 changes: 6 additions & 0 deletions machine/diagnostics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ namespace rubinius {

recurring_reports_.insert(diagnostic);
}

void remove_report(Diagnostic* diagnostic) {
std::lock_guard<std::mutex> guard(lock_);

recurring_reports_.erase(diagnostic);
}
};
}
}
Expand Down
23 changes: 19 additions & 4 deletions machine/diagnostics/codedb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,29 @@

namespace rubinius {
namespace diagnostics {
class CodeDBMetrics {
class CodeDBMetrics : public Diagnostic {
public:
metric load_ns;
metric load_count;

CodeDBMetrics() {
load_ns = 0;
load_count = 0;
CodeDBMetrics()
: Diagnostic()
, load_ns(0)
, load_count(0)
{
set_type("CodeDBMetrics");
}

virtual void start_reporting(STATE) {
if(state->shared().config.diagnostics_codedb_enabled) {
Diagnostic::start_reporting(state);
}
}

virtual void stop_reporting(STATE) {
if(state->shared().config.diagnostics_codedb_enabled) {
Diagnostic::stop_reporting(state);
}
}
};
}
Expand Down
21 changes: 18 additions & 3 deletions machine/diagnostics/concurrency.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,26 @@

namespace rubinius {
namespace diagnostics {
struct LockMetrics {
struct LockMetrics : public Diagnostic {
metric stop_the_world_ns;

LockMetrics() {
stop_the_world_ns = 0;
LockMetrics()
: Diagnostic()
, stop_the_world_ns(0)
{
set_type("ConcurrencyMetrics");
}

virtual void start_reporting(STATE) {
if(state->shared().config.diagnostics_machine_enabled) {
Diagnostic::start_reporting(state);
}
}

virtual void stop_reporting(STATE) {
if(state->shared().config.diagnostics_machine_enabled) {
Diagnostic::stop_reporting(state);
}
}
};
}
Expand Down
23 changes: 19 additions & 4 deletions machine/diagnostics/console.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,29 @@

namespace rubinius {
namespace diagnostics {
class ConsoleMetrics {
class ConsoleMetrics : public Diagnostic {
public:
metric requests_received;
metric responses_sent;

ConsoleMetrics() {
requests_received = 0;
responses_sent = 0;
ConsoleMetrics()
: Diagnostic()
, requests_received(0)
, responses_sent(0)
{
set_type("ConsoleMetrics");
}

virtual void start_reporting(STATE) {
if(state->shared().config.diagnostics_console_enabled) {
Diagnostic::start_reporting(state);
}
}

virtual void stop_reporting(STATE) {
if(state->shared().config.diagnostics_console_enabled) {
Diagnostic::stop_reporting(state);
}
}
};
}
Expand Down
10 changes: 10 additions & 0 deletions machine/diagnostics/diagnostic.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef RBX_DIAGNOSTICS_DIAGNOSTIC_HPP
#define RBX_DIAGNOSTICS_DIAGNOSTIC_HPP

#include "configuration.hpp"

#include <rapidjson/document.h>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>
Expand All @@ -22,6 +24,14 @@ namespace rubinius {

virtual ~Diagnostic() {}

virtual void start_reporting(STATE) {
state->shared().diagnostics()->add_report(this);
}

virtual void stop_reporting(STATE) {
state->shared().diagnostics()->remove_report(this);
}

virtual void update() {}

virtual void set_type(const char* type) {
Expand Down
53 changes: 34 additions & 19 deletions machine/diagnostics/gc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace rubinius {
namespace diagnostics {
class GCMetrics {
class GCMetrics : public Diagnostic {
public:
metric young_set;
metric young_count;
Expand All @@ -25,24 +25,39 @@ namespace rubinius {
metric handles_set;
metric resource_set;

GCMetrics() {
young_set = 0;
young_count = 0;
young_ms = 0;
immix_set = 0;
immix_count = 0;
immix_stop_ms = 0;
immix_suspend_ms = 0;
immix_concurrent_ms = 0;
immix_diagnostics_us = 0;
large_set = 0;
large_count = 0;
large_sweep_us = 0;
objects_queued = 0;
objects_finalized = 0;
headers_set = 0;
handles_set = 0;
resource_set = 0;
GCMetrics()
: Diagnostic()
, young_set(0)
, young_count(0)
, young_ms(0)
, immix_set(0)
, immix_count(0)
, immix_stop_ms(0)
, immix_suspend_ms(0)
, immix_concurrent_ms(0)
, immix_diagnostics_us(0)
, large_set(0)
, large_count(0)
, large_sweep_us(0)
, objects_queued(0)
, objects_finalized(0)
, headers_set(0)
, handles_set(0)
, resource_set(0)
{
set_type("GCMetrics");
}

virtual void start_reporting(STATE) {
if(state->shared().config.diagnostics_gc_enabled) {
Diagnostic::start_reporting(state);
}
}

virtual void stop_reporting(STATE) {
if(state->shared().config.diagnostics_gc_enabled) {
Diagnostic::stop_reporting(state);
}
}
};
}
Expand Down
39 changes: 27 additions & 12 deletions machine/diagnostics/jit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace rubinius {
namespace diagnostics {
class JITMetrics {
class JITMetrics : public Diagnostic {
public:
metric methods_queued;
metric methods_compiled;
Expand All @@ -18,17 +18,32 @@ namespace rubinius {
metric inlined_primitives;
metric inlined_ffi;

JITMetrics() {
methods_queued = 0;
methods_compiled = 0;
methods_failed = 0;
compile_time_us = 0;
uncommon_exits = 0;
inlined_accessors = 0;
inlined_methods = 0;
inlined_blocks = 0;
inlined_primitives = 0;
inlined_ffi = 0;
JITMetrics()
: Diagnostic()
, methods_queued(0)
, methods_compiled(0)
, methods_failed(0)
, compile_time_us(0)
, uncommon_exits(0)
, inlined_accessors(0)
, inlined_methods(0)
, inlined_blocks(0)
, inlined_primitives(0)
, inlined_ffi(0)
{
set_type("JITMetrics");
}

virtual void start_reporting(STATE) {
if(state->shared().config.diagnostics_jit_enabled) {
Diagnostic::start_reporting(state);
}
}

virtual void stop_reporting(STATE) {
if(state->shared().config.diagnostics_jit_enabled) {
Diagnostic::stop_reporting(state);
}
}
};
}
Expand Down
Loading

0 comments on commit c8bb677

Please sign in to comment.