summaryrefslogtreecommitdiff
path: root/yjit.rb
diff options
context:
space:
mode:
authorJimmy Miller <jimmy.miller@shopify.com>2022-11-10 12:56:22 -0500
committerGitHub <noreply@github.com>2022-11-10 12:56:22 -0500
commit8b3347950e6344474430ed08f5fa19f613883660 (patch)
treea932fb4a9e0e51cc4c81bc5e6325d945ea99c03f /yjit.rb
parent0de3bc92b4fc3bb9fc0930e98baed37044ed44e1 (diff)
downloadruby-8b3347950e6344474430ed08f5fa19f613883660.tar.gz
Enable --yjit-stats for release builds (#6694)
* Enable --yjit-stats for release builds In order for people in the real world to report information about how their application runs with YJIT, we want to expose stats without requiring rebuilding ruby. We can do this without overhead, with the exception of count ratio in yjit, since this relies on the interpreter also counting instructions. This change exposes those stats, while not showing ratio in yjit if we are not in a stats build. * Update yjit.rb Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com> Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
Diffstat (limited to 'yjit.rb')
-rw-r--r--yjit.rb20
1 files changed, 13 insertions, 7 deletions
diff --git a/yjit.rb b/yjit.rb
index 21f2eea4de..595faa1bb3 100644
--- a/yjit.rb
+++ b/yjit.rb
@@ -158,14 +158,17 @@ module RubyVM::YJIT
# Average length of instruction sequences executed by YJIT
avg_len_in_yjit = retired_in_yjit.to_f / total_exits
- # Proportion of instructions that retire in YJIT
- total_insns_count = retired_in_yjit + stats[:vm_insns_count]
- yjit_ratio_pct = 100.0 * retired_in_yjit.to_f / total_insns_count
+ # This only available on yjit stats builds
+ if stats.key?(:vm_insns_count)
+ # Proportion of instructions that retire in YJIT
+ total_insns_count = retired_in_yjit + stats[:vm_insns_count]
+ yjit_ratio_pct = 100.0 * retired_in_yjit.to_f / total_insns_count
+ stats[:ratio_in_yjit] = yjit_ratio_pct
+ end
# Make those stats available in RubyVM::YJIT.runtime_stats as well
stats[:side_exit_count] = side_exits
stats[:total_exit_count] = total_exits
- stats[:ratio_in_yjit] = yjit_ratio_pct
stats[:avg_len_in_yjit] = avg_len_in_yjit
stats
@@ -263,13 +266,16 @@ module RubyVM::YJIT
$stderr.puts "freed_page_count: " + ("%10d" % stats[:freed_page_count])
$stderr.puts "code_gc_count: " + ("%10d" % stats[:code_gc_count])
$stderr.puts "num_gc_obj_refs: " + ("%10d" % stats[:num_gc_obj_refs])
-
$stderr.puts "side_exit_count: " + ("%10d" % stats[:side_exit_count])
$stderr.puts "total_exit_count: " + ("%10d" % stats[:side_exit_count])
$stderr.puts "total_insns_count: " + ("%10d" % stats[:total_exit_count])
- $stderr.puts "vm_insns_count: " + ("%10d" % stats[:vm_insns_count])
+ if stats.has_key?(:vm_insns_count)
+ $stderr.puts "vm_insns_count: " + ("%10d" % stats[:vm_insns_count])
+ end
$stderr.puts "yjit_insns_count: " + ("%10d" % stats[:exec_instruction])
- $stderr.puts "ratio_in_yjit: " + ("%9.1f" % stats[:ratio_in_yjit]) + "%"
+ if stats.has_key?(:ratio_in_yjit)
+ $stderr.puts "ratio_in_yjit: " + ("%9.1f" % stats[:ratio_in_yjit]) + "%"
+ end
$stderr.puts "avg_len_in_yjit: " + ("%10.1f" % stats[:avg_len_in_yjit])
print_sorted_exit_counts(stats, prefix: "exit_")