Skip to content

Pin benchmarks to a CPU on Windows - #549

Merged
hsbt merged 3 commits into
mainfrom
claude/awesome-feynman-433d72
Oct 10, 2026
Merged

hsbt merged 3 commits into
mainfrom
claude/awesome-feynman-433d72

Conversation

@hsbt

@hsbt hsbt commented Oct 10, 2026

Copy link
Copy Markdown
Member

On Windows, benchmarks are never pinned because taskset is Linux only. On my Ryzen AI 9 HX 370, an unpinned benchmark moves between Zen 5 and Zen 5c cores, which differ in speed by about 30%. The binarytrees benchmark on YJIT took 101-105 ms with 4-6% variation between iterations.

With this change, the runner passes the CPU it would give taskset through RUBY_BENCH_PIN_CPU, and the harness pins itself with SetProcessAffinityMask. The same benchmark then took 90-95 ms with 2-5% variation. A pinned benchmark also takes HIGH_PRIORITY_CLASS, which only affects its own CPU, and opts out of power throttling. If pinning fails, the benchmark runs unpinned with a warning.

The first commit fixes load_fiddle, which left $VERBOSE nil after fiddle failed to load and silenced that warning.

Generated with Claude Code

hsbt and others added 3 commits October 10, 2026 18:34
$VERBOSE stayed nil after a LoadError from require 'fiddle', which silenced the warning of the caller that rescued it and every later one in the benchmark.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without taskset, the runner passes the CPU through RUBY_BENCH_PIN_CPU and the harness pins itself with SetProcessAffinityMask. On a Ryzen AI 9 HX 370, an unpinned run moves between Zen5 and Zen5c cores, which differ in speed by about 30%. The CPU is chosen as on Linux and is a Zen5 one there.

A failure to pin, for example without fiddle, leaves the benchmark running unpinned with a warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pinned benchmark still shares its CPU with whatever else Windows runs there, and in one pinned run fib and nbody on the interpreter varied by over 25% between iterations. The harness now also takes HIGH_PRIORITY_CLASS, which preempts other processes on that CPU only, and turns off the EXECUTION_SPEED power throttling that Windows 11 may apply to a process without a visible window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hsbt
hsbt merged commit ef59d05 into main Oct 10, 2026
11 checks passed
@hsbt
hsbt deleted the claude/awesome-feynman-433d72 branch October 10, 2026 21:40
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