Skip to content

Run the revision comparison on the host, without Docker - #64

Merged
galekseev merged 2 commits into
masterfrom
bench/native-without-docker
Aug 8, 2026
Merged

Run the revision comparison on the host, without Docker#64
galekseev merged 2 commits into
masterfrom
bench/native-without-docker

Conversation

@galekseev

Copy link
Copy Markdown

Summary

The benchmark image cannot measure an Apple GPU: a container on macOS is a Linux virtual machine, the GPU is not passed into it, and the image registers the NVIDIA ICD anyway. Rebuilding it for linux/arm64 would change the CPU architecture and nothing else.

This adds a native path alongside the Docker one, using the same runner for both:

WORK=$(bench/prepare-native.sh 9011bcd pr/57)
BENCH_ROOT=$WORK bench/run-benchmark.sh --mode leading --repeats 3
  • bench/prepare-native.sh (new) does on the host what the src and build stages of bench/Dockerfile do inside the image: resolves both revisions, exports each with git archive, runs make, and lays out a/, b/, the .ref/.sha labels and timer.state. It reads the local repository by default, so a commit you already have needs no network, and --repo <url> clones for a fork or for pull request refs that were never fetched. The workdir is named after the two commits, so rerunning the same pair skips the compilation.
  • bench/run-benchmark.sh becomes portable. Three things blocked it outside the image: /opt/bench was hardcoded (now BENCH_ROOT, same default), macOS ships bash 3.2 where local -A and ${slot^^} do not exist, and the OpenCL check needs clinfo, which macOS does not have (a Darwin host without it now counts as one platform, leaving the real check to profanity2's own device enumeration).
  • bench-logs/M4Max.mac.log records the first native run.

Nothing here is macOS-only - the same two commands work on any host with an OpenCL runtime, without building an image.

What the run says

The two revisions come out even on an Apple GPU, medians 252.6 against 252.0 MH/s, so the roughly 9% that #57 gains on an RTX 3060 does not carry over to Metal's OpenCL. The runner flags the run as noise and on the reported spread it is right - a cold first run for A and a high third run for B stretch it to 44% and 58% - but the medians are robust to both, and the last three pairs sit between 236 and 253 MH/s for either revision. That resolves a regression of about 5% or larger and nothing finer, which is what the run was for.

Test plan

  • bench/prepare-native.sh 9011bcd pr57-head builds both revisions and prints the workdir
  • Layout verified: separate directories, distinct kernel caches per revision (cache-opencl.255.4276261784 vs ...23368600), timer.state = same
  • Runner passes bash -n under bash 3.2 and runs end to end there, checked against stub binaries with known speeds
  • Short run on the GPU: Apple M4 Max, 40 compute units, -w 64 accepted with no local work size abandoned
  • Full six-repeat run, output committed as bench-logs/M4Max.mac.log
  • Error paths: unresolvable ref, identical revisions, missing arguments, unknown flag, pr/<n> without fetched refs
  • Docker path unchanged - ROOT still defaults to /opt/bench, but not re-run on an NVIDIA host in this branch

Made with Cursor

galekseev and others added 2 commits August 8, 2026 19:09
A container on macOS is a Linux virtual machine and the Apple GPU is not
passed into it, so the benchmark image cannot measure one: there is no
counterpart to the NVIDIA Container Toolkit, and the image registers the
NVIDIA ICD in any case. Building the image for linux/arm64 would change the
CPU architecture and nothing else.

prepare-native.sh does on the host what the src and build stages of the
Dockerfile do inside the image - it resolves both revisions, exports each one
with git archive, runs make in it, and leaves the layout run-benchmark.sh
expects - so the same runner serves both paths. It reads the local repository
by default, since the commits are usually already there and an export keeps
the working tree out of the build.

Three things kept the runner from working outside the image: /opt/bench was
hardcoded, macOS ships bash 3.2 where `local -A` and ${slot^^} do not exist,
and the OpenCL check relies on clinfo, which macOS does not have. A Darwin
host without clinfo is now treated as having one platform, leaving the real
check to profanity2's own device enumeration.

Nothing here is macOS-only: the same two commands compare two revisions on
any host with a working OpenCL runtime.

Co-authored-by: Cursor <cursoragent@cursor.com>
The two revisions come out even on an Apple GPU - medians 252.6 against
252.0 MH/s - so the roughly 9% that pull request 57 gains on an RTX 3060
does not carry over to Metal's OpenCL.

The runner flags the run as noise, and on the reported spread it is right:
a cold first run for A and a high third run for B stretch it to 44% and 58%.
The medians are robust to both, and the last three pairs, measured once the
machine had settled, sit between 236 and 253 MH/s for either revision. That
resolves a regression of about 5% or larger and nothing finer, which is
enough for what the run was for.

Co-authored-by: Cursor <cursoragent@cursor.com>
@galekseev
galekseev merged commit 4a21c99 into master Aug 8, 2026
1 check passed
@galekseev
galekseev deleted the bench/native-without-docker branch August 8, 2026 21:33
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