Skip to content

Use raw trace args for line coverage#3

Merged
samuel-williams-shopify merged 1 commit into
mainfrom
use-raw-tracearg-line-hook
Jun 15, 2026
Merged

Use raw trace args for line coverage#3
samuel-williams-shopify merged 1 commit into
mainfrom
use-raw-tracearg-line-hook

Conversation

@samuel-williams-shopify

Copy link
Copy Markdown
Contributor

This switches the RUBY_EVENT_LINE hook to rb_add_event_hook2 with RUBY_EVENT_HOOK_FLAG_RAW_ARG and reads line event location via rb_tracearg_path / rb_tracearg_lineno instead of rb_sourcefile / rb_sourceline.

The behavior should be equivalent for line events, and it aligns the extension with CRuby's raw trace argument API. It also means the extension will benefit from ruby/ruby#17332 if CRuby starts pre-filling line event path/line in the trace arg.

Performance check on Ruby 4.0.5 (ruby 4.0.5 (2026-05-20 revision 64336ffd0e) +PRISM [arm64-darwin25]), using alternating fresh subprocesses and the same loaded-file loop workload:

  source avg=  62.27ms min=  60.03ms max=  64.36ms samples=61.13,61.31,62.66,62.39,61.26,64.36,64.12,63.08,61.74,60.03,62.89
tracearg avg=  62.15ms min=  55.45ms max=  65.49ms samples=60.84,65.49,62.98,60.93,62.26,64.39,64.51,62.38,55.45,61.93,62.52
tracearg/source ratio: 0.998x

So on Ruby 4.0.5 this is effectively performance-neutral within measurement noise.

Verification:

/Users/samuel/.rubies/ruby-4.0.5/bin/ruby -Ilib -Iext -e 'require "ruby/coverage"; tracer = Ruby::Coverage::Tracer.new { [] }; tracer.start; 1.times{}; tracer.stop; puts :ok'
#=> ok

I could not run the full project test suite under this local Ruby 4.0.5 because the test executables were not installed in that gem environment (sus / bake missing).

@samuel-williams-shopify samuel-williams-shopify merged commit 95180d8 into main Jun 15, 2026
22 of 28 checks passed
@samuel-williams-shopify samuel-williams-shopify deleted the use-raw-tracearg-line-hook branch June 15, 2026 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant