3 ms·
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
by birn559 1y 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.
- flohofwoe 1y agoDaniel Lemire did some measuring ~~recently~~ (oops, in 2012): https://lemire.me/blog/2012/05/31/data-alignment-for-speed-myth-or-reality/ 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 :)
- birn559 1y agoWasn't aware of that, thanks for the link!
- xxs 1y ago> 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