r/programming • u/fagnerbrack • Sep 02 '26
Data Access Patterns That Makes Your CPU Really Angry
https://blog.weineng.me/posts/slowest_add/
80
Upvotes
r/programming • u/fagnerbrack • Sep 02 '26
19
u/lurking_bishop Sep 03 '26
Shouldn't a smart enough compiler be able to recognize and undo the weird access pattern since the calculation happens completely side-effect free? Runtime allocation via
rand()doesn't change the fact that the pattern is fully known at compile time.Only fisher-yates-shuffle in the repo would still survive against that since now you're genuinely don't know the access pattern beforehand
27
u/dignityshredder Sep 02 '26
tl;dr blow the cache
-20
u/PhosXD Sep 02 '26
Omg bro
`uint32_t const* positions`
WHAT KIND OF MAD MAN PUTS CONST AFTER THE TYPE, & NOT EVEN INCLUDE THE POINTER DECL IN THE TYPE EITHER.
`const uint32_t* positions` supremacy.
-3
u/metahivemind Sep 03 '26 edited Sep 11 '26
[removed] — view removed comment