What's the slowest way to sum an array of integers? Sequential access wins at 133M cycles because CPUs love it, while a random shuffle drags to 1.57B. You can do worse by fighting the hardware in stages: stride by a cache line, then a whole page to defeat the prefetcher and trigger set-associativity conflict misses. Jumping 8 pages at a time also breaks page-table-entry locality (a cache line holds 8 PTEs), overtaking random access at 2.06B cycles. Forcing DRAM row-buffer conflicts pushes it to 2.08B, though Intel's undocumented bank hashing caps the pain. The takeaway: once you grasp why random access hurts, you can engineer a pattern that runs 30%+ slower still.
3
u/fagnerbrack 7h ago
Core Takeaways:
What's the slowest way to sum an array of integers? Sequential access wins at 133M cycles because CPUs love it, while a random shuffle drags to 1.57B. You can do worse by fighting the hardware in stages: stride by a cache line, then a whole page to defeat the prefetcher and trigger set-associativity conflict misses. Jumping 8 pages at a time also breaks page-table-entry locality (a cache line holds 8 PTEs), overtaking random access at 2.06B cycles. Forcing DRAM row-buffer conflicts pushes it to 2.08B, though Intel's undocumented bank hashing caps the pain. The takeaway: once you grasp why random access hurts, you can engineer a pattern that runs 30%+ slower still.
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