Skip to content

Commit

Permalink
Converted Metrics to only counters.
Browse files Browse the repository at this point in the history
Counters preserve their characteristics under sampling (ie they lose
resolution but not accuracy) and counters can be used in pairs to
simulate a gauge.
  • Loading branch information
brixen committed Jun 23, 2015
1 parent 5e55964 commit d1c4443
Show file tree
Hide file tree
Showing 15 changed files with 136 additions and 223 deletions.
24 changes: 12 additions & 12 deletions kernel/common/gc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ def self.count

def self.time
data = stat
data[:"gc.young.total.ms"] +
data[:"gc.immix.stop.total.ms"] +
data[:"gc.large.sweep.total.ms"]
data[:"gc.young.ms"] +
data[:"gc.immix.stop.ms"] +
data[:"gc.large.sweep.ms"]
end

def self.stat
Expand Down Expand Up @@ -54,22 +54,22 @@ def self.result
===================================
Collections
Count Total time / concurrent (ms) Last time / concurrent (ms)
Young #{sprintf("% 22d", stats[:'gc.young.count'])} #{sprintf("% 16d ", stats[:'gc.young.total.ms'])} #{sprintf("% 16d ", stats[:'gc.young.last.ms'])}
Full #{sprintf("% 22d", stats[:'gc.immix.count'])} #{sprintf("% 16d / % 10d", stats[:'gc.immix.stop.total.ms'], stats[:'gc.immix.concurrent.total.ms'])} #{sprintf("% 16d / % 10d", stats[:'gc.immix.stop.last.ms'], stats[:'gc.immix.concurrent.last.ms'])}
Count Total time / concurrent (ms)
Young #{sprintf("% 22d", stats[:'gc.young.count'])} #{sprintf("% 16d ", stats[:'gc.young.ms'])}
Full #{sprintf("% 22d", stats[:'gc.immix.count'])} #{sprintf("% 16d / % 10d", stats[:'gc.immix.stop.ms'], stats[:'gc.immix.concurrent.ms'])}
Allocation
Objects allocated Bytes allocated
Young #{sprintf("% 22d", stats[:'memory.young.objects.total'])} #{sprintf("% 22d", stats[:'memory.young.bytes.total'])}
Promoted#{sprintf("% 22d", stats[:'memory.promoted.objects.total'])} #{sprintf("% 22d", stats[:'memory.promoted.bytes.total'])}
Mature #{sprintf("% 22d", stats[:'memory.immix.objects.total'])} #{sprintf("% 22d", stats[:'memory.immix.bytes.total'])}
Young #{sprintf("% 22d", stats[:'memory.young.objects'])} #{sprintf("% 22d", stats[:'memory.young.bytes'])}
Promoted#{sprintf("% 22d", stats[:'memory.promoted.objects'])} #{sprintf("% 22d", stats[:'memory.promoted.bytes'])}
Mature #{sprintf("% 22d", stats[:'memory.immix.objects'])} #{sprintf("% 22d", stats[:'memory.immix.bytes'])}
Usage
Bytes used
Young #{sprintf("% 22d", stats[:'memory.young.bytes.current'])}
Mature #{sprintf("% 22d", stats[:'memory.immix.bytes.current'])}
Large #{sprintf("% 22d", stats[:'memory.large.bytes.current'])}
Young #{sprintf("% 22d", stats[:'memory.young.bytes'])}
Mature #{sprintf("% 22d", stats[:'memory.immix.bytes'])}
Large #{sprintf("% 22d", stats[:'memory.large.bytes'])}
Code #{sprintf("% 22d", stats[:'memory.code.bytes'])}
Symbols #{sprintf("% 22d", stats[:'memory.symbols.bytes'])}
OUT
Expand Down
4 changes: 2 additions & 2 deletions vm/builtin/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace rubinius {
state->memory()->needs_finalization(data, (FinalizerFunction)&Data::finalize);
}

state->vm()->metrics().m.ruby_metrics.memory_data_objects_total++;
state->vm()->metrics().m.ruby_metrics.memory_data_objects++;

return data;
}
Expand Down Expand Up @@ -76,7 +76,7 @@ namespace rubinius {
state->memory()->needs_finalization(data, (FinalizerFunction)&Data::finalize);
}

state->vm()->metrics().m.ruby_metrics.memory_data_objects_total++;
state->vm()->metrics().m.ruby_metrics.memory_data_objects++;

return data;
}
Expand Down
3 changes: 1 addition & 2 deletions vm/builtin/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ namespace rubinius {
state->memory()->needs_finalization(thr, (FinalizerFunction)&Thread::finalize,
FinalizeObject::eUnmanaged);

state->vm()->metrics().system_metrics.vm_threads++;
state->vm()->metrics().system_metrics.vm_threads_total++;
state->vm()->metrics().system_metrics.vm_threads_created++;

return thr;
}
Expand Down
2 changes: 1 addition & 1 deletion vm/gc/immix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace rubinius {
#endif

if(object_memory_) {
object_memory_->state()->metrics().m.ruby_metrics.memory_immix_chunks_total++;
object_memory_->state()->metrics().m.ruby_metrics.memory_immix_chunks++;

if(gc_->dec_chunks_left() <= 0) {
gc_->reset_chunks_left();
Expand Down
8 changes: 2 additions & 6 deletions vm/gc/immix_marker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ namespace rubinius {
if(data_) {
{
timer::StopWatch<timer::milliseconds> timer(
state->vm()->metrics().m.ruby_metrics.gc_immix_conc_last_ms,
state->vm()->metrics().m.ruby_metrics.gc_immix_conc_total_ms
);
state->vm()->metrics().m.ruby_metrics.gc_immix_concurrent_ms);

// Allow for a young stop the world GC to occur
// every bunch of marks. 100 is a fairly arbitrary
Expand All @@ -100,9 +98,7 @@ namespace rubinius {

{
timer::StopWatch<timer::milliseconds> timer(
state->vm()->metrics().m.ruby_metrics.gc_immix_stop_last_ms,
state->vm()->metrics().m.ruby_metrics.gc_immix_stop_total_ms
);
state->vm()->metrics().m.ruby_metrics.gc_immix_stop_ms);

// Finish and pause
while(!state->stop_the_world()) {
Expand Down
6 changes: 1 addition & 5 deletions vm/gc/mark_sweep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ namespace rubinius {
object_memory_->state()->metrics().m.ruby_metrics.memory_large_objects++;
object_memory_->state()->metrics().m.ruby_metrics.memory_large_bytes += bytes;

object_memory_->state()->metrics().m.ruby_metrics.memory_large_objects_total++;
object_memory_->state()->metrics().m.ruby_metrics.memory_large_bytes_total += bytes;

next_collection_bytes -= bytes;
if(next_collection_bytes < 0) {
*collect_now = true;
Expand Down Expand Up @@ -126,8 +123,7 @@ namespace rubinius {
metrics::MetricsData& metrics = object_memory_->state()->metrics();

timer::StopWatch<timer::milliseconds> timer(
metrics.m.ruby_metrics.gc_large_sweep_last_ms,
metrics.m.ruby_metrics.gc_large_sweep_total_ms);
metrics.m.ruby_metrics.gc_large_sweep_ms);

last_freed = 0;

Expand Down
9 changes: 3 additions & 6 deletions vm/instruments/timing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,19 @@ namespace timer {

template <int factor=milliseconds>
class StopWatch {
uint64_t& lap_;
uint64_t& total_;
uint64_t start_;

public:
StopWatch(uint64_t& lap, uint64_t& total)
: lap_(lap)
, total_(total)
StopWatch(uint64_t& total)
: total_(total)
{
start_ = get_current_time();
}

~StopWatch() {
uint64_t now = get_current_time();
lap_ = (now - start_) / ((uint64_t)factor);
total_ += lap_;
total_ += (now - start_) / ((uint64_t)factor);
}
};

Expand Down
3 changes: 1 addition & 2 deletions vm/llvm/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,7 @@ namespace rubinius {

{
timer::StopWatch<timer::microseconds> timer(
metrics().m.jit_metrics.time_last_us,
metrics().m.jit_metrics.time_total_us);
metrics().m.jit_metrics.time_us);

jit.compile(compile_request);

Expand Down
105 changes: 34 additions & 71 deletions vm/metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,56 +227,36 @@ namespace rubinius {
metrics_map_.push_back(new MetricsItem(
"jit.methods.failed", metrics_collection_.jit_metrics.methods_failed));
metrics_map_.push_back(new MetricsItem(
"jit.time.last.us", metrics_collection_.jit_metrics.time_last_us));
metrics_map_.push_back(new MetricsItem(
"jit.time.total.us", metrics_collection_.jit_metrics.time_total_us));
"jit.time.us", metrics_collection_.jit_metrics.time_us));

// Object memory metrics
metrics_map_.push_back(new MetricsItem(
"memory.young.bytes.current",
"memory.young.bytes",
metrics_collection_.ruby_metrics.memory_young_bytes));
metrics_map_.push_back(new MetricsItem(
"memory.young.bytes.total",
metrics_collection_.ruby_metrics.memory_young_bytes_total));
metrics_map_.push_back(new MetricsItem(
"memory.young.objects.current",
"memory.young.objects",
metrics_collection_.ruby_metrics.memory_young_objects));
metrics_map_.push_back(new MetricsItem(
"memory.young.objects.total",
metrics_collection_.ruby_metrics.memory_young_objects_total));
"memory.young.occupancy",
metrics_collection_.ruby_metrics.memory_young_occupancy));
metrics_map_.push_back(new MetricsItem(
"memory.young.percent_used",
metrics_collection_.ruby_metrics.memory_young_percent_used));
metrics_map_.push_back(new MetricsItem(
"memory.immix.bytes.current",
"memory.immix.bytes",
metrics_collection_.ruby_metrics.memory_immix_bytes));
metrics_map_.push_back(new MetricsItem(
"memory.immix.bytes.total",
metrics_collection_.ruby_metrics.memory_immix_bytes_total));
metrics_map_.push_back(new MetricsItem(
"memory.immix.objects.current",
"memory.immix.objects",
metrics_collection_.ruby_metrics.memory_immix_objects));
metrics_map_.push_back(new MetricsItem(
"memory.immix.objects.total",
metrics_collection_.ruby_metrics.memory_immix_objects_total));
metrics_map_.push_back(new MetricsItem(
"memory.immix.chunks.current",
"memory.immix.chunks",
metrics_collection_.ruby_metrics.memory_immix_chunks));
metrics_map_.push_back(new MetricsItem(
"memory.immix.chunks.total",
metrics_collection_.ruby_metrics.memory_immix_chunks_total));
metrics_map_.push_back(new MetricsItem(
"memory.large.bytes.current",
"memory.large.bytes",
metrics_collection_.ruby_metrics.memory_large_bytes));
metrics_map_.push_back(new MetricsItem(
"memory.large.bytes.total",
metrics_collection_.ruby_metrics.memory_large_bytes_total));
metrics_map_.push_back(new MetricsItem(
"memory.large.objects.current",
"memory.large.objects",
metrics_collection_.ruby_metrics.memory_large_objects));
metrics_map_.push_back(new MetricsItem(
"memory.large.objects.total",
metrics_collection_.ruby_metrics.memory_large_objects_total));
"memory.symbols",
metrics_collection_.ruby_metrics.memory_symbols));
metrics_map_.push_back(new MetricsItem(
"memory.symbols.bytes",
metrics_collection_.ruby_metrics.memory_symbols_bytes));
Expand All @@ -285,25 +265,22 @@ namespace rubinius {
metrics_map_.push_back(new MetricsItem(
"memory.jit.bytes", metrics_collection_.ruby_metrics.memory_jit_bytes));
metrics_map_.push_back(new MetricsItem(
"memory.promoted.bytes.total",
metrics_collection_.ruby_metrics.memory_promoted_bytes_total));
"memory.promoted.bytes",
metrics_collection_.ruby_metrics.memory_promoted_bytes));
metrics_map_.push_back(new MetricsItem(
"memory.promoted.objects.total",
metrics_collection_.ruby_metrics.memory_promoted_objects_total));
"memory.promoted.objects",
metrics_collection_.ruby_metrics.memory_promoted_objects));
metrics_map_.push_back(new MetricsItem(
"memory.slab.refills.total",
metrics_collection_.ruby_metrics.memory_slab_refills_total));
"memory.slab.refills",
metrics_collection_.ruby_metrics.memory_slab_refills));
metrics_map_.push_back(new MetricsItem(
"memory.slab.refills.fails",
metrics_collection_.ruby_metrics.memory_slab_refills_fails));
metrics_map_.push_back(new MetricsItem(
"memory.data_objects.total",
metrics_collection_.ruby_metrics.memory_data_objects_total));
"memory.data_objects",
metrics_collection_.ruby_metrics.memory_data_objects));
metrics_map_.push_back(new MetricsItem(
"memory.capi_handles.total",
metrics_collection_.ruby_metrics.memory_capi_handles_total));
metrics_map_.push_back(new MetricsItem(
"memory.capi_handles.current",
"memory.capi_handles",
metrics_collection_.ruby_metrics.memory_capi_handles));
metrics_map_.push_back(new MetricsItem(
"memory.inflated_headers",
Expand All @@ -313,33 +290,22 @@ namespace rubinius {
metrics_map_.push_back(new MetricsItem(
"gc.young.count", metrics_collection_.ruby_metrics.gc_young_count));
metrics_map_.push_back(new MetricsItem(
"gc.young.last.ms", metrics_collection_.ruby_metrics.gc_young_last_ms));
metrics_map_.push_back(new MetricsItem(
"gc.young.total.ms", metrics_collection_.ruby_metrics.gc_young_total_ms));
"gc.young.ms", metrics_collection_.ruby_metrics.gc_young_ms));
metrics_map_.push_back(new MetricsItem(
"gc.young.lifetime", metrics_collection_.ruby_metrics.gc_young_lifetime));
metrics_map_.push_back(new MetricsItem(
"gc.immix.count", metrics_collection_.ruby_metrics.gc_immix_count));
metrics_map_.push_back(new MetricsItem(
"gc.immix.stop.last.ms",
metrics_collection_.ruby_metrics.gc_immix_stop_last_ms));
metrics_map_.push_back(new MetricsItem(
"gc.immix.stop.total.ms",
metrics_collection_.ruby_metrics.gc_immix_stop_total_ms));
"gc.immix.stop.ms",
metrics_collection_.ruby_metrics.gc_immix_stop_ms));
metrics_map_.push_back(new MetricsItem(
"gc.immix.concurrent.last.ms",
metrics_collection_.ruby_metrics.gc_immix_conc_last_ms));
metrics_map_.push_back(new MetricsItem(
"gc.immix.concurrent.total.ms",
metrics_collection_.ruby_metrics.gc_immix_conc_total_ms));
"gc.immix.concurrent.ms",
metrics_collection_.ruby_metrics.gc_immix_concurrent_ms));
metrics_map_.push_back(new MetricsItem(
"gc.large.count", metrics_collection_.ruby_metrics.gc_large_count));
metrics_map_.push_back(new MetricsItem(
"gc.large.sweep.last.ms",
metrics_collection_.ruby_metrics.gc_large_sweep_last_ms));
metrics_map_.push_back(new MetricsItem(
"gc.large.sweep.total.ms",
metrics_collection_.ruby_metrics.gc_large_sweep_total_ms));
"gc.large.sweep.ms",
metrics_collection_.ruby_metrics.gc_large_sweep_ms));

// I/O metrics
metrics_map_.push_back(new MetricsItem(
Expand All @@ -360,19 +326,16 @@ namespace rubinius {
"vm.inline_cache.resets",
metrics_collection_.system_metrics.vm_inline_cache_resets));
metrics_map_.push_back(new MetricsItem(
"vm.threads.current",
metrics_collection_.system_metrics.vm_threads));
"vm.threads.created",
metrics_collection_.system_metrics.vm_threads_created));
metrics_map_.push_back(new MetricsItem(
"vm.threads.total",
metrics_collection_.system_metrics.vm_threads_total));
"vm.threads.destroyed",
metrics_collection_.system_metrics.vm_threads_destroyed));

// Lock metrics
metrics_map_.push_back(new MetricsItem(
"locks.stop_the_world.last.ns",
metrics_collection_.system_metrics.locks_stop_the_world_last_ns));
metrics_map_.push_back(new MetricsItem(
"locks.stop_the_world.total.ns",
metrics_collection_.system_metrics.locks_stop_the_world_total_ns));
"locks.stop_the_world.ns",
metrics_collection_.system_metrics.locks_stop_the_world_ns));
}

void Metrics::init_ruby_metrics(STATE) {
Expand Down
Loading

0 comments on commit d1c4443

Please sign in to comment.