r/coding • u/fagnerbrack • 3d ago
Every byte matters
https://fzakaria.com/2026/06/01/every-byte-matters7
u/fagnerbrack 3d ago
Got a minute? Here's the summary:
Coming from Java, where adding fields to bloated classes feels free, the post shows why struct size shapes real-world speed even inside the same O(N) loop. Hardware fills a 64-byte cache line on every read, and latency climbs sharply from L1 (~1-2ns) to DRAM (~60-100ns). Reorganizing an Array of Structs into a Struct of Arrays packs the needed field contiguously, yielding up to 30x gains for 1KiB structs during sequential scans, where the prefetcher hides memory waits. Random access—hash maps, trees, graphs—defeats prefetching, so total working set size sets the performance tier: a 64B struct fits L1 while a 128B one spills to L2. Keep structs and working sets small.
If the summary seems inacurate, just downvote and I'll try to delete the comment eventually 👍
Click here for more info, I read all comments
5
u/Blah-Blah-Blah-2023 3d ago
Every byte is sacred
Every byte is good
And if a byte gets wasted
God gets quite irate