Skip to content

Pin benchmarks on Windows from the runner - #556

Open
k0kubun wants to merge 2 commits into
ruby:mainfrom
k0kubun:windows-pinning-from-runner
Open

k0kubun wants to merge 2 commits into
ruby:mainfrom
k0kubun:windows-pinning-from-runner

Conversation

@k0kubun

@k0kubun k0kubun commented Oct 13, 2026

Copy link
Copy Markdown
Member

Follow-up to #549. On Linux, the runner pins a benchmark from outside with `taskset`, but on Windows the benchmark pinned itself in `harness-common.rb`. That loaded Fiddle and kept kernel32 open in the process being measured. It also only covered harnesses that load `harness-common.rb`, so `harness-spinel` was left unpinned even though `pin?` selects Spinel.

A child process inherits its parent's affinity mask when it is created. So the runner now narrows its own mask around `Process.spawn` and restores it right after, and the child starts on the CPU `taskset` would give it. The priority class is not inherited, so the runner sets `HIGH_PRIORITY_CLASS` and the power-throttling opt-out on the child by PID while Ruby boots, before the harness takes any timings. If pinning fails, the benchmark runs unpinned with a warning, as before.

`RUBY_BENCH_PIN_CPU` is gone, and the harness no longer has Windows-specific code. The `load_fiddle` fix from #549 is kept.

On Linux the runner pins a benchmark from outside with taskset, but on
Windows the benchmark pinned itself in harness-common.rb. That loaded
Fiddle and kept kernel32 open in the process being measured, only
covered harnesses that load harness-common.rb, and left harness-spinel
unpinned even though pin? selects Spinel.

A child process inherits the affinity mask of its parent when it is
created, so the runner now narrows its own mask around Process.spawn
and restores it right after. The child starts on the CPU it would be
given with taskset. The priority class is not inherited, so the runner
sets HIGH_PRIORITY_CLASS and the power throttling opt-out on the child
by its PID while Ruby boots, before the harness takes any timings. If
pinning fails, the benchmark runs unpinned with a warning as before.

RUBY_BENCH_PIN_CPU is gone, and the harness no longer has
Windows-specific code. The load_fiddle fix from ruby#549 is kept.
@k0kubun
k0kubun marked this pull request as ready for review October 13, 2026 23:04
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