Skip to content

Pin benchmarks on Windows from the runner - #556

Merged
k0kubun merged 2 commits into
ruby:mainfrom
k0kubun:windows-pinning-from-runner
Oct 15, 2026
Merged

k0kubun merged 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.

This PR moves the CPU pinning code for Windows from the benchmark harness to the benchmark driver.

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

@hsbt hsbt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on mswin. Pinned benchmarks run with affinity 0x80, High priority and execution speed throttling turned off, and --no-pinning leaves them unchanged.

The pinning from #549 still takes effect as before, so this looks good to me 👌

@k0kubun
k0kubun merged commit d9f8b47 into ruby:main Oct 15, 2026
15 checks passed
@k0kubun
k0kubun deleted the windows-pinning-from-runner branch October 15, 2026 18:22
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