summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandy Stauner <randy@r4s6.net>2025-11-05 11:30:00 -0700
committerGitHub <noreply@github.com>2025-11-05 13:30:00 -0500
commitd327eb6046ad9dc0bb6c24ceb23ce69061011164 (patch)
treeb839ff3af640654bad2dd1dc4cd5d0842d88583c
parentdf290e11d928e67b0ffdf3cc767e0d4ad6f01b29 (diff)
ZJIT: Track guard shape exit ratio (#15052)
new ZJIT stats excerpt from liquid-runtime: ``` vm_read_from_parent_iseq_local_count: 10,909,753 guard_type_count: 45,109,441 guard_type_exit_ratio: 4.3% guard_shape_count: 15,272,133 guard_shape_exit_ratio: 20.1% code_region_bytes: 3,899,392 ``` lobsters ``` guard_type_count: 71,765,580 guard_type_exit_ratio: 4.3% guard_shape_count: 21,872,560 guard_shape_exit_ratio: 8.0% ``` railsbench ``` guard_type_count: 117,661,124 guard_type_exit_ratio: 0.7% guard_shape_count: 28,032,665 guard_shape_exit_ratio: 5.1% ``` shipit ``` guard_type_count: 106,195,615 guard_type_exit_ratio: 3.5% guard_shape_count: 33,672,673 guard_shape_exit_ratio: 10.1% ```
-rw-r--r--zjit.rb5
-rw-r--r--zjit/src/codegen.rs1
-rw-r--r--zjit/src/stats.rs1
3 files changed, 6 insertions, 1 deletions
diff --git a/zjit.rb b/zjit.rb
index cfe8bcd6e2..5156c72f43 100644
--- a/zjit.rb
+++ b/zjit.rb
@@ -152,6 +152,7 @@ class << RubyVM::ZJIT
stats = self.stats
stats[:guard_type_exit_ratio] = stats[:exit_guard_type_failure].to_f / stats[:guard_type_count] * 100
+ stats[:guard_shape_exit_ratio] = stats[:exit_guard_shape_failure].to_f / stats[:guard_shape_count] * 100
# Show counters independent from exit_* or dynamic_send_*
print_counters_with_prefix(prefix: 'not_inlined_cfuncs_', prompt: 'not inlined C methods', buf:, stats:, limit: 20)
@@ -206,6 +207,8 @@ class << RubyVM::ZJIT
:guard_type_count,
:guard_type_exit_ratio,
+ :guard_shape_count,
+ :guard_shape_exit_ratio,
:code_region_bytes,
:side_exit_count,
@@ -242,7 +245,7 @@ class << RubyVM::ZJIT
case key
when :ratio_in_zjit
value = '%0.1f%%' % value
- when :guard_type_exit_ratio
+ when :guard_type_exit_ratio, :guard_shape_exit_ratio
value = '%0.1f%%' % value
when /_time_ns\z/
key = key.to_s.sub(/_time_ns\z/, '_time')
diff --git a/zjit/src/codegen.rs b/zjit/src/codegen.rs
index 01212ac88c..364b9225fe 100644
--- a/zjit/src/codegen.rs
+++ b/zjit/src/codegen.rs
@@ -964,6 +964,7 @@ fn gen_array_extend(jit: &mut JITState, asm: &mut Assembler, left: Opnd, right:
}
fn gen_guard_shape(jit: &mut JITState, asm: &mut Assembler, val: Opnd, shape: ShapeId, state: &FrameState) -> Opnd {
+ gen_incr_counter(asm, Counter::guard_shape_count);
let shape_id_offset = unsafe { rb_shape_id_offset() };
let val = asm.load(val);
let shape_opnd = Opnd::mem(SHAPE_ID_NUM_BITS as u8, val, shape_id_offset);
diff --git a/zjit/src/stats.rs b/zjit/src/stats.rs
index 30a0966994..aea28db28b 100644
--- a/zjit/src/stats.rs
+++ b/zjit/src/stats.rs
@@ -286,6 +286,7 @@ make_counters! {
// The number of times we ran a dynamic check
guard_type_count,
+ guard_shape_count,
}
/// Increase a counter by a specified amount