Skip to content

Say whether the availability estimate measured the machine - #13

Merged
MuteJester merged 1 commit into
mainfrom
parallelism/report-whether-availability-was-measured
Nov 15, 2026
Merged

MuteJester merged 1 commit into
mainfrom
parallelism/report-whether-availability-was-measured

Conversation

@MuteJester

Copy link
Copy Markdown
Owner

Follow-up to #12, which merged before this commit landed. #12 gave macOS and
Windows a contention estimate; this is the part that lets anyone check it is
working.

Why #12 is not verifiable as merged

#12 passed all fifteen checks, and that proved nothing about whether the new
estimate ever runs. On a quiet machine available == cores whether the reading
worked or fell back to "assume no contention", so a working estimate and a dead
code path produce identical output. The platform reports from #12 show exactly
that ambiguity:

macOS:   BEAM 1.0.0.dev0, darwin, 3 cores, 3 OpenMP threads
Windows: BEAM 1.0.0.dev0, win32,  4 cores, 4 OpenMP threads
Linux:   BEAM 1.0.0.dev0, linux,  4 cores, 4 OpenMP threads

threads == cores on every platform — which is what an idle machine gives, and
also what -1 gives. Those platforms could have stayed on the fallback with
every leg green, and so could any future regression that broke the readers.

This is the same shape as the thread-plan wiring line: a green check whose claim
was stronger than its evidence.

What this adds

parallel_plan() reports available_measured beside available, filled from
the same single reading via beam_available_cores_ex(&measured).

Not from a second reading, and that matters: on the sampled platforms a sample
consumes the window it is measured over, so a probe that re-read would report
"not measured" almost always and would perturb the signal it claims to describe.
A pin counts as measured — the estimate then came from outside rather than from
the fallback.

BeamPlanIn carries it as a reporting-only field. beam_plan_threads() does
not read it and must not: a plan that behaved differently depending on whether
the estimate was measured would turn the fallback into a second policy rather
than a missing input.

The test is mutation-tested, which is the whole point

test_the_estimate_says_whether_it_measured_the_machine calls parallel_plan()
twice either side of a 30 ms sleep (the sampled platforms need a window; the
first reading on a thread is only a baseline) and asserts the flag is true.

Pointing the Linux reader at /proc/loadavg_absent makes the machine never
answer, and the test fails with assert False is True. Restored, it passes.

So a pass on the macOS and Windows legs is now evidence that the sampled path
measures
, rather than evidence that it compiles. That evidence did not exist
for #12 and cannot be obtained from it.

Two C tests go with it: a pin counts as measured (true on every platform, unlike
a bare reading), and beam_available_cores() is exactly
beam_available_cores_ex(NULL) under a pin, which removes the per-call freedom
the sampled platforms otherwise have and makes the comparison exact.

Verified

  • C suite: 452 tests, 0 failed
  • Python suite: 1242 passed, 2 skipped
  • Gate: exit 0, no FAIL and no note lines; every recorded number
    byte-identical
  • The detector itself mutation-tested, as above

Baselines moved by four lines across three inventory files — pytest_cases 1243
→ 1244, c_cases 450 → 452, c_symbols 263 → 264 — each named in
RERECORDED.md.

CI passed on all fifteen checks with the sampled estimate in place, and that
proved nothing about whether the estimate ever ran. On a quiet runner
available == cores whether the reading worked or fell back to "assume no
contention", so a working estimate and a dead code path produce identical
output. The platform report confirms it: macOS resolved 3 threads on 3 cores
and Windows 4 on 4, which is what an idle machine gives AND what -1 gives.

That is the same shape as the thread-plan wiring line -- a green check whose
claim was stronger than its evidence -- so parallel_plan() now reports
available_measured beside available.

It is filled from the SAME single reading, through
beam_available_cores_ex(&measured), not from a second one. Asking twice would
take a second sample, and on the sampled platforms a sample consumes the
window it is measured over: a probe that re-read would report "not measured"
almost always and would perturb the signal it claims to describe. A pin
counts as measured, since the estimate then came from outside rather than
from the fallback.

BeamPlanIn carries it as a reporting-only field. beam_plan_threads() does not
read it and must not: a plan that behaved differently depending on whether
the estimate was measured would make the fallback a second policy rather than
a missing input.

The Python test is mutated against the real build, which is the only reason
it is worth having. Pointing the Linux reader at /proc/loadavg_absent makes
the machine never answer and the test fails with `assert False is True`;
restored, it passes. So a pass on the macOS and Windows legs is now evidence
that the sampled path MEASURES, rather than evidence that it compiles.

Verified: C 452 tests all passing, Python 1242 passed and 2 skipped, gate
exit 0 with no FAIL and no note lines, every recorded number byte-identical.
Three inventory files moved by four lines in total, named in RERECORDED.md.
@MuteJester
MuteJester merged commit 3c52e43 into main Nov 15, 2026
15 checks passed
@MuteJester
MuteJester deleted the parallelism/report-whether-availability-was-measured branch November 15, 2026 13:05
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