Skip to content

defk-wnu: measure the code-layout noise band and state the rule - #84

Merged
DanielLuning merged 1 commit into
mainfrom
defk-wnu/layout-noise-band
Oct 26, 2026
Merged

DanielLuning merged 1 commit into
mainfrom
defk-wnu/layout-noise-band

Conversation

@DanielLuning

Copy link
Copy Markdown
Owner

What changed

Owner decision 2026-10-26: make the layout noise visible first (this PR); the -falign-* experiment is the follow-up defk-w8r.4, measured with this band.

  • bench/layout_noise.exs: builds one module of five kernels 8 times with only the code addresses moved. A CC wrapper per build passes -include of a header with an unused function of 0-48 bytes, so every function after it moves by that many bytes (checked with nm -n on the built .so files; the C differs only in the module name in ERL_NIF_INIT, which is data). The first build is also measured under two more labels as an A/A control. Interleaved rounds, the order rotated each round, best of 3 per label per round; it prints per-label medians, the layout range, the same-build range and count_primes' round-bests.
  • docs/performance.md: new entry 1.10 with the numbers; 1.7 points to it and gets the rule (a difference inside a kernel's layout range can be layout alone); 1.7's source line no longer calls defk-9p6.24 open.

Results

Quiet machine (other processes 0.65-0.67 cores), 15 rounds, one run:

kernel layout range (8 builds) same-build range (3 labels)
count_primes(300_000) 3.6% 0.8%
count_primes_via_call(300_000) 2.9% 0.2%
count_primes_early(1_000_000) 3.6% 2.1%
sum, 1M [f64] 1.9% 0.8%
dot, 2 x 1M [f64] 1.2% 1.2%

The integer loops move with layout well beyond their control (pad 40 made count_primes ~3% faster than pad 0 in 10 of 11 rounds outside a slow stretch); the float loops do not clearly. Rounds 8-11 were 8-10% slower for every build at once; the interleaving spreads that over all builds. A first 9-round run without the control gave the same picture (layout ranges 0.4-4.1%).

How it was checked

mix ci on an M-series Mac in the worktree: 2326 tests passed. No test runs the bench scripts; the script was smoke-run and then run in full.

  • Touches a promised surface? No: a bench script and the maintainers' performance record, so no CHANGELOG.md entry.
  • Touches test/stability/? No.

bench/layout_noise.exs builds one kernel 8 times with only its code
addresses moved (an unused function of 0-48 bytes before it, through a CC
wrapper) and measures the first build under two more labels as an A/A
control. On a quiet machine, 15 rounds: integer loops move 2.9-3.6% with
layout against 0.2-2.1% for the control; sum and dot 1.2-1.9%, near their
control. docs/performance.md gets entry 1.10 and the rule in 1.7: a
difference inside a kernel's layout range can be layout alone.
DanielLuning pushed a commit that referenced this pull request Oct 26, 2026
… ../defk-wnu). Quiet run 2026-10-26, 15 rounds: integer loops layout range 2.9-3.6% vs A/A control 0.2-2.1%; sum/dot 1.2-1.9%, near control. mix ci passed. Close after merge; defk-w8r.4 then unblocks."
@DanielLuning
DanielLuning merged commit d832a21 into main Oct 26, 2026
2 checks passed
@DanielLuning
DanielLuning deleted the defk-wnu/layout-noise-band branch October 26, 2026 13:17
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