ruby-changes:68994
From: Noah <ko1@a...>
Date: Thu, 21 Oct 2021 08:19:37 +0900 (JST)
Subject: [ruby-changes:68994] 25792c17d4 (master): Convert yjit static stat variables to counters
https://git.ruby-lang.org/ruby.git/commit/?id=25792c17d4 From 25792c17d44f4097ad5aedee87b4369cfdbef9f7 Mon Sep 17 00:00:00 2001 From: Noah Gibbs <noah.gibbs@s...> Date: Mon, 28 Jun 2021 18:06:03 +0100 Subject: Convert yjit static stat variables to counters --- yjit_core.c | 2 +- yjit_iface.c | 12 ++++-------- yjit_iface.h | 4 +++- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/yjit_core.c b/yjit_core.c index e90347237f..c4f18e872f 100644 --- a/yjit_core.c +++ b/yjit_core.c @@ -344,7 +344,7 @@ add_block_version(blockid_t blockid, block_t* block) https://github.com/ruby/ruby/blob/trunk/yjit_core.c#L344 #if RUBY_DEBUG // First block compiled for this iseq - rb_compiled_iseq_count++; + yjit_runtime_counters.compiled_iseq_count++; #endif } diff --git a/yjit_iface.c b/yjit_iface.c index 3d589f5e5e..0794ac9c32 100644 --- a/yjit_iface.c +++ b/yjit_iface.c @@ -26,9 +26,7 @@ static VALUE mYjit; https://github.com/ruby/ruby/blob/trunk/yjit_iface.c#L26 static VALUE cYjitBlock; #if RUBY_DEBUG -static int64_t vm_insns_count = 0; static int64_t exit_op_count[VM_INSTRUCTION_SIZE] = { 0 }; -int64_t rb_compiled_iseq_count = 0; struct rb_yjit_runtime_counters yjit_runtime_counters = { 0 }; static VALUE cYjitCodeComment; #endif @@ -761,8 +759,6 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/yjit_iface.c#L759 reset_stats_bang(rb_execution_context_t *ec, VALUE self) { #if RUBY_DEBUG - vm_insns_count = 0; - rb_compiled_iseq_count = 0; memset(&exit_op_count, 0, sizeof(exit_op_count)); memset(&yjit_runtime_counters, 0, sizeof(yjit_runtime_counters)); #endif // if RUBY_DEBUG @@ -777,7 +773,7 @@ reset_stats_bang(rb_execution_context_t *ec, VALUE self) https://github.com/ruby/ruby/blob/trunk/yjit_iface.c#L773 void rb_yjit_collect_vm_usage_insn(int insn) { - vm_insns_count++; + yjit_runtime_counters.vm_insns_count++; } void @@ -903,16 +899,16 @@ print_yjit_stats(void) https://github.com/ruby/ruby/blob/trunk/yjit_iface.c#L899 double avg_len_in_yjit = (double)retired_in_yjit / total_exit_count; // Proportion of instructions that retire in YJIT - int64_t total_insns_count = retired_in_yjit + vm_insns_count; + int64_t total_insns_count = retired_in_yjit + yjit_runtime_counters.vm_insns_count; double ratio = retired_in_yjit / (double)total_insns_count; - fprintf(stderr, "compiled_iseq_count: %10" PRId64 "\n", rb_compiled_iseq_count); + fprintf(stderr, "compiled_iseq_count: %10" PRId64 "\n", yjit_runtime_counters.compiled_iseq_count); fprintf(stderr, "inline_code_size: %10d\n", cb->write_pos); fprintf(stderr, "outlined_code_size: %10d\n", ocb->write_pos); fprintf(stderr, "total_exit_count: %10" PRId64 "\n", total_exit_count); fprintf(stderr, "total_insns_count: %10" PRId64 "\n", total_insns_count); - fprintf(stderr, "vm_insns_count: %10" PRId64 "\n", vm_insns_count); + fprintf(stderr, "vm_insns_count: %10" PRId64 "\n", yjit_runtime_counters.vm_insns_count); fprintf(stderr, "yjit_insns_count: %10" PRId64 "\n", yjit_runtime_counters.exec_instruction); fprintf(stderr, "ratio_in_yjit: %9.1f%%\n", ratio * 100); fprintf(stderr, "avg_len_in_yjit: %10.1f\n", avg_len_in_yjit); diff --git a/yjit_iface.h b/yjit_iface.h index f0980eaf3f..cfb2764454 100644 --- a/yjit_iface.h +++ b/yjit_iface.h @@ -75,6 +75,9 @@ YJIT_DECLARE_COUNTERS( https://github.com/ruby/ruby/blob/trunk/yjit_iface.h#L75 binding_allocations, binding_set, + vm_insns_count, + compiled_iseq_count, + // Member with known name for iterating over counters last_member ) @@ -93,7 +96,6 @@ extern yjit_comment_array_t yjit_code_comments; https://github.com/ruby/ruby/blob/trunk/yjit_iface.h#L96 #endif // if RUBY_DEBUG RUBY_EXTERN struct rb_yjit_options rb_yjit_opts; -RUBY_EXTERN int64_t rb_compiled_iseq_count; RUBY_EXTERN struct rb_yjit_runtime_counters yjit_runtime_counters; void cb_write_pre_call_bytes(codeblock_t* cb); -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/