Skip to content

Commit 1978e7f

Browse files
rwstaunerjacob-shops
authored andcommitted
ZJIT: Track guard shape exit ratio (ruby#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% ```
1 parent 9cb0aa4 commit 1978e7f

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

zjit.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def stats_string
152152
stats = self.stats
153153

154154
stats[:guard_type_exit_ratio] = stats[:exit_guard_type_failure].to_f / stats[:guard_type_count] * 100
155+
stats[:guard_shape_exit_ratio] = stats[:exit_guard_shape_failure].to_f / stats[:guard_shape_count] * 100
155156

156157
# Show counters independent from exit_* or dynamic_send_*
157158
print_counters_with_prefix(prefix: 'not_inlined_cfuncs_', prompt: 'not inlined C methods', buf:, stats:, limit: 20)
@@ -206,6 +207,8 @@ def stats_string
206207

207208
:guard_type_count,
208209
:guard_type_exit_ratio,
210+
:guard_shape_count,
211+
:guard_shape_exit_ratio,
209212

210213
:code_region_bytes,
211214
:side_exit_count,
@@ -242,7 +245,7 @@ def print_counters(keys, buf:, stats:, right_align: false, base: nil)
242245
case key
243246
when :ratio_in_zjit
244247
value = '%0.1f%%' % value
245-
when :guard_type_exit_ratio
248+
when :guard_type_exit_ratio, :guard_shape_exit_ratio
246249
value = '%0.1f%%' % value
247250
when /_time_ns\z/
248251
key = key.to_s.sub(/_time_ns\z/, '_time')

zjit/src/codegen.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,7 @@ fn gen_array_extend(jit: &mut JITState, asm: &mut Assembler, left: Opnd, right:
964964
}
965965

966966
fn gen_guard_shape(jit: &mut JITState, asm: &mut Assembler, val: Opnd, shape: ShapeId, state: &FrameState) -> Opnd {
967+
gen_incr_counter(asm, Counter::guard_shape_count);
967968
let shape_id_offset = unsafe { rb_shape_id_offset() };
968969
let val = asm.load(val);
969970
let shape_opnd = Opnd::mem(SHAPE_ID_NUM_BITS as u8, val, shape_id_offset);

zjit/src/stats.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ make_counters! {
286286

287287
// The number of times we ran a dynamic check
288288
guard_type_count,
289+
guard_shape_count,
289290
}
290291

291292
/// Increase a counter by a specified amount

0 commit comments

Comments
 (0)