Skip to content

Commit

Permalink
Improved cache metrics.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Apr 17, 2016
1 parent 628fe1c commit 54bed47
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 13 deletions.
2 changes: 2 additions & 0 deletions machine/builtin/call_site.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace rubinius {
cache->executable(state, executable);
cache->ip(ip);

state->vm()->metrics().machine.call_site_count++;

return cache;
}

Expand Down
8 changes: 8 additions & 0 deletions machine/builtin/mono_inline_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ namespace rubinius {
cache->method_missing(dis.method_missing);
cache->hits(1);

state->vm()->metrics().machine.inline_cache_count++;

return cache;
}

Expand All @@ -71,10 +73,13 @@ namespace rubinius {

if(likely(cache->receiver_data().raw == recv_data)) {
cache->hit();
state->vm()->metrics().machine.inline_cache_hits++;
state->vm()->metrics().machine.methods_invoked++;
return cache->method()->execute(state, cache->method(), cache->stored_module(), args);
}

state->vm()->metrics().machine.inline_cache_misses++;

return call_site->fallback(state, args);
}

Expand All @@ -88,12 +93,15 @@ namespace rubinius {

if(likely(cache->receiver_data().raw == recv_data)) {
cache->hit();
state->vm()->metrics().machine.inline_cache_hits++;
state->vm()->metrics().machine.methods_invoked++;
state->vm()->set_method_missing_reason(cache->method_missing());
args.unshift(state, call_site->name());
return cache->method()->execute(state, cache->method(), cache->stored_module(), args);
}

state->vm()->metrics().machine.inline_cache_misses++;

return call_site->fallback(state, args);
}

Expand Down
8 changes: 8 additions & 0 deletions machine/builtin/poly_inline_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace rubinius {
cache->method_missing(dis.method_missing);
cache->hits(hits);

state->vm()->metrics().machine.inline_cache_count++;

return cache;
}

Expand Down Expand Up @@ -102,11 +104,14 @@ namespace rubinius {
Executable* meth = entry->method();
Module* mod = entry->stored_module();
entry->hit();
state->vm()->metrics().machine.inline_cache_hits++;
state->vm()->metrics().machine.methods_invoked++;

return meth->execute(state, meth, mod, args);
}

state->vm()->metrics().machine.inline_cache_misses++;

return cache->fallback(state, args);
}

Expand All @@ -126,11 +131,14 @@ namespace rubinius {
Executable* meth = entry->method();
Module* mod = entry->stored_module();
entry->hit();
state->vm()->metrics().machine.inline_cache_hits++;
state->vm()->metrics().machine.methods_invoked++;

return meth->execute(state, meth, mod, args);
}

state->vm()->metrics().machine.inline_cache_misses++;

return cache->fallback(state, args);
}

Expand Down
2 changes: 1 addition & 1 deletion machine/builtin/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ namespace rubinius {
state->vm()->global_cache()->clear(state, name);
mod->reset_method_cache(state, name);

state->vm()->metrics().machine.inline_cache_resets++;
state->vm()->metrics().machine.cache_resets++;

if(state->shared().config.ic_debug) {
String* mod_name = mod->get_name(state);
Expand Down
6 changes: 6 additions & 0 deletions machine/global_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,17 @@ namespace rubinius {
msg.module = entry->module;
msg.visibility = entry->visibility;

state->vm()->metrics().machine.global_cache_hits++;

return true;
}
}

state->vm()->metrics().machine.global_cache_misses++;

if(hierarchy_resolve(state, name, msg, lookup)) {
state->vm()->metrics().machine.global_cache_count++;

retain_i(state, klass, name,
msg.module, msg.method, msg.visibility);

Expand Down
22 changes: 19 additions & 3 deletions machine/metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,31 @@ namespace rubinius {
metrics_map_.push_back(new MetricsItem(
"machine.checkpoints", metrics_data_.machine.checkpoints));
metrics_map_.push_back(new MetricsItem(
"machine.inline_cache.resets", metrics_data_.machine.inline_cache_resets));
"machine.stops", metrics_data_.machine.stops));
metrics_map_.push_back(new MetricsItem(
"machine.backtraces", metrics_data_.machine.backtraces));
"machine.global_cache.count", metrics_data_.machine.global_cache_count));
metrics_map_.push_back(new MetricsItem(
"machine.backtrace.us", metrics_data_.machine.backtrace_us));
"machine.global_cache.hits", metrics_data_.machine.global_cache_hits));
metrics_map_.push_back(new MetricsItem(
"machine.global_cache.misses", metrics_data_.machine.global_cache_misses));
metrics_map_.push_back(new MetricsItem(
"machine.call_site.count", metrics_data_.machine.call_site_count));
metrics_map_.push_back(new MetricsItem(
"machine.inline_cache.count", metrics_data_.machine.inline_cache_count));
metrics_map_.push_back(new MetricsItem(
"machine.inline_cache.hits", metrics_data_.machine.inline_cache_hits));
metrics_map_.push_back(new MetricsItem(
"machine.inline_cache.misses", metrics_data_.machine.inline_cache_misses));
metrics_map_.push_back(new MetricsItem(
"machine.cache.resets", metrics_data_.machine.cache_resets));
metrics_map_.push_back(new MetricsItem(
"machine.methods.invoked", metrics_data_.machine.methods_invoked));
metrics_map_.push_back(new MetricsItem(
"machine.blocks.invoked", metrics_data_.machine.blocks_invoked));
metrics_map_.push_back(new MetricsItem(
"machine.backtraces", metrics_data_.machine.backtraces));
metrics_map_.push_back(new MetricsItem(
"machine.backtrace.us", metrics_data_.machine.backtrace_us));
metrics_map_.push_back(new MetricsItem(
"machine.bytecode.load.us", metrics_data_.machine.bytecode_load_us));
metrics_map_.push_back(new MetricsItem(
Expand Down
39 changes: 30 additions & 9 deletions machine/metrics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,23 +162,37 @@ namespace rubinius {
struct MachineMetrics {
metric checkpoints;
metric stops;
metric inline_cache_resets;
metric backtraces;
metric backtrace_us;
metric global_cache_count;
metric global_cache_hits;
metric global_cache_misses;
metric call_site_count;
metric inline_cache_count;
metric inline_cache_hits;
metric inline_cache_misses;
metric cache_resets;
metric methods_invoked;
metric blocks_invoked;
metric backtraces;
metric backtrace_us;
metric bytecode_load_us;
metric bytecode_verifier_us;
metric bytecode_internalizer_us;

MachineMetrics() {
checkpoints = 0;
stops = 0;
inline_cache_resets = 0;
backtraces = 0;
backtrace_us = 0;
global_cache_count = 0;
global_cache_hits = 0;
global_cache_misses = 0;
call_site_count = 0;
inline_cache_count = 0;
inline_cache_hits = 0;
inline_cache_misses = 0;
cache_resets = 0;
methods_invoked = 0;
blocks_invoked = 0;
backtraces = 0;
backtrace_us = 0;
bytecode_load_us = 0;
bytecode_verifier_us = 0;
bytecode_internalizer_us = 0;
Expand All @@ -187,11 +201,18 @@ namespace rubinius {
void add(MachineMetrics& data) {
checkpoints += data.checkpoints;
stops += data.stops;
inline_cache_resets += data.inline_cache_resets;
backtraces += data.backtraces;
backtrace_us += data.backtrace_us;
call_site_count += data.call_site_count;
global_cache_count += data.global_cache_count;
global_cache_hits += data.global_cache_hits;
global_cache_misses += data.global_cache_misses;
inline_cache_count += data.inline_cache_count;
inline_cache_hits += data.inline_cache_hits;
inline_cache_misses += data.inline_cache_misses;
cache_resets += data.cache_resets;
methods_invoked += data.methods_invoked;
blocks_invoked += data.blocks_invoked;
backtraces += data.backtraces;
backtrace_us += data.backtrace_us;
bytecode_load_us += data.bytecode_load_us;
bytecode_verifier_us += data.bytecode_verifier_us;
bytecode_internalizer_us += data.bytecode_internalizer_us;
Expand Down

0 comments on commit 54bed47

Please sign in to comment.