prometheus_exporter icon indicating copy to clipboard operation
prometheus_exporter copied to clipboard

Add YJIT metrics to `Process`

Open erickguan opened this issue 11 months ago • 0 comments

Hey!

I want to add a few metrics about YJIT in the Process instrumentation to understand the YJIT performance.

These metrics depend on the RUBYOPT=--yjit-stats flag and Ruby::YJIT.runtime_stats API. When the Ruby process starts with --yjit-stats or RUBYOPT=--yjit-stats, the Ruby::YJIT.runtime_stats produces performance stats. Otherwise, Ruby::YJIT.runtime_stats returns nil. Naturally, I would propose to add:

  1. A new function collect_yjit_metrics in the Process#collect.
  2. collect_yjit_metrics collects:
    • ratio_in_yjit: the percentage of total YARV instructions executed by YJIT as opposed to the CRuby interpreter
    • code_region_size
    • yjit_alloc_size
    • code_gc_count
    • compiled_iseq_count
    • yjit_insns_count
    • side_exit_count
    • total_exit_count
    • avg_len_in_yjit

Reference: Ruby YJIT Docuementation

erickguan avatar Jan 20 '25 14:01 erickguan