diff options
author | Jean Boussier <[email protected]> | 2021-08-24 12:32:07 +0200 |
---|---|---|
committer | Alan Wu <[email protected]> | 2021-10-20 18:19:39 -0400 |
commit | 0dc3bba6f2b2b1b23e1ec9dd2ec29f932c292db0 (patch) | |
tree | c9db52ed439e6cf7fc3f48622718ce418f3b3849 /yjit_iface.c | |
parent | 2ba090a1f9258035b40374f9ff9da3ff920701cd (diff) |
Allow to compile with --yjit-stats support but not the full RUBY_DEBUG
RUBY_DEBUG have a very significant performance overhead. Enough that
YJIT with RUBY_DEBUG is noticeably slower than the interpreter without
RUBY_DEBUG.
This makes it hard to collect yjit-stats in production environments.
By allowing to collect JIT statistics without the RUBy_DEBUG overhead,
I hope to make such use cases smoother.
Diffstat (limited to 'yjit_iface.c')
-rw-r--r-- | yjit_iface.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/yjit_iface.c b/yjit_iface.c index 90b4ed9555..8ad6005bb9 100644 --- a/yjit_iface.c +++ b/yjit_iface.c @@ -25,11 +25,18 @@ static VALUE mYjit; static VALUE cYjitBlock; #if RUBY_DEBUG -static int64_t exit_op_count[VM_INSTRUCTION_SIZE] = { 0 }; -struct rb_yjit_runtime_counters yjit_runtime_counters = { 0 }; +# define YJIT_STATS 1 static VALUE cYjitCodeComment; +#else +# ifndef YJIT_STATS +# define YJIT_STATS 0 +# endif +#endif +#if YJIT_STATS extern const int rb_vm_max_insn_name_size; +static int64_t exit_op_count[VM_INSTRUCTION_SIZE] = { 0 }; +struct rb_yjit_runtime_counters yjit_runtime_counters = { 0 }; #endif // Machine code blocks (executable memory) @@ -721,7 +728,7 @@ get_yjit_stats(rb_execution_context_t *ec, VALUE self) rb_hash_aset(hash, key, value); } -#if RUBY_DEBUG +#if YJIT_STATS if (rb_yjit_opts.gen_stats) { // Indicate that the complete set of stats is available rb_hash_aset(hash, ID2SYM(rb_intern("all_stats")), Qtrue); @@ -783,16 +790,16 @@ get_yjit_stats(rb_execution_context_t *ec, VALUE self) static VALUE reset_stats_bang(rb_execution_context_t *ec, VALUE self) { -#if RUBY_DEBUG +#if YJIT_STATS memset(&exit_op_count, 0, sizeof(exit_op_count)); memset(&yjit_runtime_counters, 0, sizeof(yjit_runtime_counters)); -#endif // if RUBY_DEBUG +#endif // if YJIT_STATS return Qnil; } #include "yjit.rbinc" -#if RUBY_DEBUG +#if YJIT_STATS void rb_yjit_collect_vm_usage_insn(int insn) { @@ -1022,9 +1029,9 @@ rb_yjit_init(struct rb_yjit_options *options) rb_yjit_opts.gen_stats |= !!getenv("YJIT_STATS"); -#if !RUBY_DEBUG +#if !YJIT_STATS if(rb_yjit_opts.gen_stats) { - rb_warning("--yjit-stats requires that Ruby is compiled with CPPFLAGS='-DRUBY_DEBUG=1'"); + rb_warning("--yjit-stats requires that Ruby is compiled with CPPFLAGS='-DYJIT_STATS=1' or CPPFLAGS='-DRUBY_DEBUG=1'"); } #endif @@ -1070,7 +1077,7 @@ rb_yjit_init(struct rb_yjit_options *options) #endif #endif - if (RUBY_DEBUG && rb_yjit_opts.gen_stats) { + if (YJIT_STATS && rb_yjit_opts.gen_stats) { // Setup at_exit callback for printing out counters rb_block_call(rb_mKernel, rb_intern("at_exit"), 0, NULL, at_exit_print_stats, Qfalse); } |