class method
ZJIT.stats_string
stats_string
zjit.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/zjit.rb, line 167
def stats_string
buf = +"***ZJIT: Printing ZJIT statistics on exit***\n"
stats = self.stats
if stats[:guard_type_count].nonzero?
stats[:guard_type_exit_ratio] = stats[:exit_guard_type_failure].to_f / stats[:guard_type_count] * 100
end
if stats[:guard_shape_count].nonzero?
stats[:guard_shape_exit_ratio] = stats[:exit_guard_shape_failure].to_f / stats[:guard_shape_count] * 100
end
# 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)
print_counters_with_prefix(prefix: 'ccall_', prompt: 'calls to C functions from JIT code', buf:, stats:, limit: 20)
# Don't show not_annotated_cfuncs right now because it mostly duplicates not_inlined_cfuncs
# print_counters_with_prefix(prefix: 'not_annotated_cfuncs_', prompt: 'not annotated C methods', buf:, stats:, limit: 20)
# Show fallback counters, ordered by the typical amount of fallbacks for the prefix at the time
print_counters_with_prefix(prefix: 'unspecialized_send_def_type_', prompt: 'not optimized method types for send', buf:, stats:, limit: 20)
print_counters_with_prefix(prefix: 'unspecialized_send_without_block_def_type_', prompt: 'not optimized method types for send_without_block', buf:, stats:, limit: 20)
print_counters_with_prefix(prefix: 'uncategorized_fallback_yarv_insn_', prompt: 'instructions with uncategorized fallback reason', buf:, stats:, limit: 20)
print_counters_with_prefix(prefix: 'send_fallback_', prompt: 'send fallback reasons', buf:, stats:, limit: 20)
print_counters_with_prefix(prefix: 'setivar_fallback_', prompt: 'setivar fallback reasons', buf:, stats:, limit: 5)
print_counters_with_prefix(prefix: 'getivar_fallback_', prompt: 'getivar fallback reasons', buf:, stats:, limit: 5)
print_counters_with_prefix(prefix: 'definedivar_fallback_', prompt: 'definedivar fallback reasons', buf:, stats:, limit: 5)
print_counters_with_prefix(prefix: 'invokeblock_handler_', prompt: 'invokeblock handler', buf:, stats:, limit: 10)
# Show most popular unsupported call features. Because each call can
# use multiple complex features, a decrease in this number does not
# necessarily mean an increase in number of optimized calls.
print_counters_with_prefix(prefix: 'complex_arg_pass_', prompt: 'popular complex argument-parameter features not optimized', buf:, stats:, limit: 10)
# Show exit counters, ordered by the typical amount of exits for the prefix at the time
print_counters_with_prefix(prefix: 'compile_error_', prompt: 'compile error reasons', buf:, stats:, limit: 20)
print_counters_with_prefix(prefix: 'unhandled_yarv_insn_', prompt: 'unhandled YARV insns', buf:, stats:, limit: 20)
print_counters_with_prefix(prefix: 'unhandled_hir_insn_', prompt: 'unhandled HIR insns', buf:, stats:, limit: 20)
print_counters_with_prefix(prefix: 'exit_', prompt: 'side exit reasons', buf:, stats:, limit: 20)
# 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,
:dynamic_setivar_count,
:dynamic_getivar_count,
:dynamic_definedivar_count,
:iseq_optimized_send_count,
:inline_cfunc_optimized_send_count,
:inline_iseq_optimized_send_count,
:non_variadic_cfunc_optimized_send_count,
:variadic_cfunc_optimized_send_count,
], buf:, stats:, right_align: true, base: :send_count)
print_counters([
:compiled_iseq_count,
:failed_iseq_count,
:compile_time_ns,
:profile_time_ns,
:gc_time_ns,
:invalidation_time_ns,
:vm_write_pc_count,
:vm_write_sp_count,
:vm_write_locals_count,
:vm_write_stack_count,
:vm_write_to_parent_iseq_local_count,
:vm_read_from_parent_iseq_local_count,
:guard_type_count,
:guard_type_exit_ratio,
:guard_shape_count,
:guard_shape_exit_ratio,
:code_region_bytes,
:zjit_alloc_bytes,
:total_mem_bytes,
:side_exit_count,
:total_insn_count,
:vm_insn_count,
:zjit_insn_count,
:ratio_in_zjit,
], buf:, stats:)
buf
end
Get the summary of ZJIT statistics as a String