module ZJIT
This module allows for introspection of ZJIT, CRuby’s just-in-time compiler. Everything in the module is highly implementation specific and the API might be less stable compared to the standard library.
This module may not exist if ZJIT does not support the particular platform for which CRuby is built.
Public Class Methods
Source
# File zjit.rb, line 18 def enabled? Primitive.cexpr! 'RBOOL(rb_zjit_enabled_p)' end
Check if ZJIT is enabled
Source
# File zjit.rb, line 33 def reset_stats! Primitive.rb_zjit_reset_stats_bang end
Discard statistics collected for ‘–zjit-stats`.
Source
# File zjit.rb, line 28 def stats(target_key = nil) Primitive.rb_zjit_stats(target_key) end
Return ZJIT statistics as a Hash
Source
# File zjit.rb, line 23 def stats_enabled? Primitive.rb_zjit_stats_enabled_p end
Check if ‘–zjit-stats` is used
Source
# File zjit.rb, line 38 def stats_string buf = +"***ZJIT: Printing ZJIT statistics on exit***\n" stats = self.stats # Show exit reasons, ordered by the typical amount of exits for the prefix at the time print_counters_with_prefix(prefix: 'unhandled_call_', prompt: 'unhandled call types', 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: 'compile_error_', prompt: 'compile error reasons', buf:, stats:, limit: 20) print_counters_with_prefix(prefix: 'exit_', prompt: 'side exit reasons', buf:, stats:, limit: 20) print_counters_with_prefix(prefix: 'dynamic_send_type_', prompt: 'dynamic send types', buf:, stats:, limit: 20) # Show the most important stats ratio_in_zjit at the end print_counters([ :dynamic_send_count, :compiled_iseq_count, :failed_iseq_count, :compile_time_ns, :profile_time_ns, :gc_time_ns, :invalidation_time_ns, :code_region_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