r/rust • u/quest_for_7c • 23h ago
Where your stack lives can move a benchmark by 50%
https://heikoseeberger.de/2026-12-01-stack-position/
13
Upvotes
r/rust • u/quest_for_7c • 23h ago
16
u/quest_for_7c 23h ago
Author here.
We added timers to tellus, a benchmark got 55% slower, and the timers weren't the cause. An unaligned 16-byte copy on every message got slow whenever it straddled two memory pages, and that depended only on where the thread's stack started. The same binary ran 67% slower just because its stack lay 96 bytes deeper.
Happy to answer questions.
18
u/vytah 22h ago
Everyone who benchmarks code should watch this: https://www.youtube.com/watch?v=r-TLSBdHe1A
TL;DW 1. Memory layout had giant impact on performance, and it's beyond developer's control. 2. Causal relationships make recognizing bottlenecks non-trivial.
6
u/AdmiralQuokka 19h ago
The Author is transparent about AI assistance, unfortunately only at the end of the text. Would be nice to have the disclaimer at the start, so readers can decide whether they want to read it or not.
Pangram reports the text as 74% AI-generated: https://www.pangram.com/history/10d22fa0-52ee-4814-b22f-4f1e17962afe
1
u/SnooWoofers170 10h ago
Really good write-up. The A/A control is the part I'm going to copy - I compare builds with interleaved runs and medians, but I've never measured the harness against itself, so a "5% faster" number from me is basically unverified.
One thing I couldn't tell from the post: was the page-split penalty ever reproducible on the x86_64 jobs, or only on your aarch64 machine? All four inconclusive null runs landing on x86_64 made me wonder.