summaryrefslogtreecommitdiff
path: root/zjit.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <takashi.kokubun@shopify.com>2025-09-30 20:50:08 -0700
committerGitHub <noreply@github.com>2025-09-30 20:50:08 -0700
commit56f777cedf1b9acc2fe74bda3d5dde351ba31951 (patch)
treef956ad497379f6fc62b4b427006c4daac2b3838d /zjit.rb
parent400e150f00ebbd71b14c9c4a885b1eb23be4b4b2 (diff)
ZJIT: Add more *_send_count stats (#14689)
Diffstat (limited to 'zjit.rb')
-rw-r--r--zjit.rb21
1 files changed, 17 insertions, 4 deletions
diff --git a/zjit.rb b/zjit.rb
index 2ff4cf2a5b..ab5bae719a 100644
--- a/zjit.rb
+++ b/zjit.rb
@@ -162,9 +162,16 @@ class << RubyVM::ZJIT
print_counters_with_prefix(prefix: 'compile_error_', prompt: 'compile error reasons', buf:, stats:, limit: 20)
print_counters_with_prefix(prefix: 'exit_', prompt: 'side exit reasons', buf:, stats:, limit: 20)
- # Show the most important stats ratio_in_zjit at the end
+ # Show no-prefix counters, having the most important stat `ratio_in_zjit` at the end
print_counters([
+ :send_count,
:dynamic_send_count,
+ :optimized_send_count,
+ :iseq_optimized_send_count,
+ :inline_cfunc_optimized_send_count,
+ :variadic_cfunc_optimized_send_count,
+ ], buf:, stats:, right_align: true, base: :send_count)
+ print_counters([
:dynamic_getivar_count,
:dynamic_setivar_count,
@@ -202,12 +209,18 @@ class << RubyVM::ZJIT
# :stopdoc:
private
- def print_counters(keys, buf:, stats:)
- left_pad = keys.map { |key| key.to_s.sub(/_time_ns\z/, '_time').size }.max + 1
+ def print_counters(keys, buf:, stats:, right_align: false, base: nil)
+ key_pad = keys.map { |key| key.to_s.sub(/_time_ns\z/, '_time').size }.max + 1
+ key_align = '-' unless right_align
+ value_pad = keys.filter_map { |key| stats[key] }.map { |value| number_with_delimiter(value).size }.max
+
keys.each do |key|
# Some stats like vm_insn_count and ratio_in_zjit are not supported on the release build
next unless stats.key?(key)
value = stats[key]
+ if base && key != base
+ ratio = " (%4.1f%%)" % (100.0 * value / stats[base])
+ end
case key
when :ratio_in_zjit
@@ -219,7 +232,7 @@ class << RubyVM::ZJIT
value = number_with_delimiter(value)
end
- buf << "#{"%-#{left_pad}s" % "#{key}:"} #{value}\n"
+ buf << "%#{key_align}*s %*s%s\n" % [key_pad, "#{key}:", value_pad, value, ratio]
end
end