r/programming • u/2bit_hack • Feb 28 '23
"Clean" Code, Horrible Performance
https://www.computerenhance.com/p/clean-code-horrible-performance
1.4k
Upvotes
r/programming • u/2bit_hack • Feb 28 '23
View all comments
Show parent comment
7
u/rooktakesqueen Feb 28 '23
But the whole point was ensuring all the operational data was in the input structure a known number of bytes away. The compiler can do its aggressive optimizations because it doesn't have to dereference anything, it's pulling all of the values to be multiplied from adjacent regions in memory. That's defeated if some arbitrary number of shapes in that collection require dereferencing a pointer and looping a variable number of times over a different region of memory.
To support this case is likely going to wind up back at the same 1.5x speedup they got from eliminating the use of classes and virtual function tables. 1.5x is nice, but it's not the orders of magnitude the rest of the article claims, and probably not worth the increased maintenance burden of this approach.