Hacker News new | ask | show | jobs
by birn559 326 days ago
My understanding is that C++ compilers still add padding by default for performance reasons. CPU will have to spend a few cycles to reorganize data that is not aligned in chunks of 4 bytes.
2 comments

Daniel Lemire did some measuring ~~recently~~ (oops, in 2012):

https://lemire.me/blog/2012/05/31/data-alignment-for-speed-m...

TL;DR: 10% difference on what in 2012 was a low-end CPU, no difference on "new in 2012" CPUs. So my guess is that by now it really doesn't matter anymore :)

Wasn't aware of that, thanks for the link!
> CPU will have to spend a few cycles to reorganize data that is not aligned in chunks of 4 bytes.

That's not true for quite a lot of CPUs. Pretty much all x64 and stuff don't care