Skip to content

add new RUBY_BENCH_CMD_PREFIX option#513

Closed
luke-gruber wants to merge 1 commit into
ruby:mainfrom
luke-gruber:bench_cmd_prefix_option
Closed

add new RUBY_BENCH_CMD_PREFIX option#513
luke-gruber wants to merge 1 commit into
ruby:mainfrom
luke-gruber:bench_cmd_prefix_option

Conversation

@luke-gruber
Copy link
Copy Markdown
Collaborator

If you want to run perf during the benchmark run, but you don't want to record any non-benchmark code, there is currently no way to do this outside of the perf harness. The perf harness has the downside that it only works with perf, and not with samply or other profilers.

RUBY_BENCH_CMD_PREFIX="perf record -g" ./run_benchmarks.rb --chruby="head::ruby_head --yjit --yjit-perf" railsbench

You can use any command you want, so it's not limited to perf:

RUBY_BENCH_CMD_PREFIX="samply record" ./run_benchmarks.rb --chruby="head::ruby_head --yjit --yjit-perf" railsbench

Note that unlike the perf harness, this wraps the entire benchmark run with the command, so even warmup iterations are recorded.

This option can be used with any command, so it's not limited to profiling.

@k0kubun
Copy link
Copy Markdown
Member

k0kubun commented May 27, 2026

I guess you didn't like -e "perf record -g /opt/rubies/ruby_head/bin/ruby ..." either, or maybe it didn't work?

If you want to run `perf` during the benchmark run, but you don't want to record any
non-benchmark code, there is currently no way to do this outside of the perf harness. The
perf harness has the downside that it only works with perf, and not with samply or other profilers.

RUBY_BENCH_CMD_PREFIX="perf record -g" ./run_benchmarks.rb --chruby="head::ruby_head --yjit --yjit-perf=map" railsbench

You can use any command you want, so it's not limited to perf:

RUBY_BENCH_CMD_PREFIX="samply record" ./run_benchmarks.rb --chruby="head::ruby_head --yjit" railsbench

Note that unlike the perf harness, this wraps the entire benchmark run with the command, so even warmup iterations are
recorded.

This option can be used with any command, so it's not limited to profiling.

You can currently run perf or samply by running the benchmark directly, but it's useful to go through `run_benchmarks.rb`
option processing and chruby switching.
@luke-gruber luke-gruber force-pushed the bench_cmd_prefix_option branch from 5278dbe to 729bcf9 Compare May 27, 2026 18:31
@luke-gruber
Copy link
Copy Markdown
Collaborator Author

I like going through run_benchmarks.rb option parsing 😆

@k0kubun
Copy link
Copy Markdown
Member

k0kubun commented May 27, 2026

Just to be clear, you're just saying you like --chruby more than -e, right?

-e is an option for run_benchmarks.rb, so even if you used -e, you'd be still going through run_benchmarks.rb option parsing.

@luke-gruber
Copy link
Copy Markdown
Collaborator Author

luke-gruber commented May 27, 2026

Oh sorry I misunderstood. I didn't realize I could use a non-ruby ruby path, thank you 👍

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.

2 participants