Repository navigation
Description
Problem
morphic-measuring-performance/references/finding-cost.md assumes that a run with the collector off keeps in memory what it allocates. Two rules rest on that:
count-on-one-thread: "SetGOMAXPROCS=1 GOGC=offfor an instruction count over a compile ... A spec too large to hold uncollected keepsGOMAXPROCS=1alone and says so." Nothing says how to tell whether a spec is held. That depends on the memory the machine has free at the time, not on the spec alone.resident-set-without-collector: "WithGOGC=offnothing is freed, so the maximum resident set/usr/bin/time -lprints beside an instruction count is every byte the run allocated."
On a loaded machine, the system reclaims the run's pages, and both readings move. These runs compiled the golden spec (cloudflare/api-schemas @904c5434) with GOMAXPROCS=1 GOGC=off /usr/bin/time -l <bin> compile -o /dev/null openapi.json, alternating two builds of the work on #2354 (b3fb238, which that PR's branch does not hold yet, and a working tree on it) and dropping each binary's first run. The machine ran macOS with 12 cores and 36 GB, at a load average of 40 to 100, on 2026-11-30:
build max resident set instructions retired
base 4,906,549,248 106,874,591,544
head 2,094,333,952 110,618,645,153
base 1,001,177,088 117,755,821,755
head 1,149,353,984 120,346,723,432
base 921,452,544 122,469,150,698
head 814,841,856 124,657,562,111
The same command, run a day earlier on two other builds of that work (4de1117, on the branch, and a head on it), read:
build instructions retired max resident set
4de111770 105,618,380,574 6,530,056,192
head 106,371,027,627 6,680,756,224
4de111770 105,863,666,945 6,529,859,584
head 106,869,563,258 6,678,085,632
4de111770 106,208,205,304 5,180,309,504
head 106,968,593,242 6,179,536,896
The compile allocates about 6.5 GB uncollected. Over six runs, the resident set fell from 4.9 GB to 0.8 GB, so it measured what the system left resident, not the allocation. As it fell, the instruction count rose in run order on both builds alike, from 106.9 G to 124.7 G (17%), where the earlier runs, at 5.2 to 6.7 GB, stayed within 1.3%. Nothing in the rules checks that a reading came from a run that held. Nor do they say what to do once a spread is wider than any gap the comparison could quote.
Direction
A draft:
- In
count-on-one-thread, say how to tell that a collector-off run held. Its maximum resident set agrees across the runs of one build to within a few percent, and with that of a run on a quiet machine. Drop a reading from a run that did not hold. Then take a spec small enough to hold, orGOMAXPROCS=1alone with the spread the rule states for it. - In
resident-set-without-collector, limit the reading to a run that held, by the same check. - Beside each cost figure, give the load average at both ends and each side's spread. Where a side's spread is wider than the gap, claim nothing. Either alternate paired runs on a smaller spec and quote medians, or measure later on a quieter machine. Say which was done.
Out of scope
- A fresh binary's first run (skills: a fresh binary's first run counts extra instructions the probes read #2360).
- Quoting a duration (skills: measuring-performance's habit sends a duration to wall time, which its rule forbids #2361).
- Whether to pin
GOMAXPROCSwhen timing a test binary.
Priority: P4, rule 1 (housekeeping): a skills change that alters no lowering, validation, IR or emit-contract behaviour. The command above → max resident set 0.81 to 4.91 GB and instructions 106.9 to 124.7 G over six runs (spec @904c5434, morphic @b3fb23899). git grep -n -i -E 'page|swap|memory pressure' origin/main -- .claude/skills/morphic-measuring-performance → no match (morphic @4a7a384c9).
Activity
OmarAlJarrah commentedon Nov 30, 2026
One more case of the same mechanism. Profiling
compilers/openapi/e2eon a macOS development machine attributed about 20% of the package's CPU profile to platform overhead (system calls and the memory allocator's page handling) that the Linux CI runner does not show. So a wall-clock or profile share measured locally overstates what CI will see, and the gap is not constant across packages. The skill could say to project CI times from instruction counts, or from a ratio against a CI run of the same package, rather than from local wall-clock time.chore(skills): reconcile new rules with their neighbours and issues
chore(skills): call no run held that the held-run check rejects
OmarAlJarrah commentedon Dec 2, 2026
More evidence for the same rule, from a machine with 12 cores at a load average of 60 to 117 (macOS, 2026-12-01): over repeated runs of the golden-spec compile, the instruction counts of one build swung about 16%, and the maximum resident set could not be read at all, for the reason this issue gives. A 1.05x difference between two builds stood only after three alternating pairs, each build run in turn, with the medians quoted; a single pair, or a block of one build's runs and then the other's, would have read either way.
So the method asked for here should also say what to do when the spread exceeds the gap: alternate paired runs, quote the medians and the load at both ends, or claim nothing.