Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Note that the key takeaway is just to order struct members by size, largest first; this isn't always sufficient, but it's a good habit wherever performance could matter.


Yeah. It's an incredibly verbose document, with that key insight buried in a mere two sentences near the end:

> The simplest way to eliminate slop is to reorder the structure members by decreasing alignment. That is: make all the pointer-aligned subfields come first, because on a 64-bit machine they will be 8 bytes. Then the 4-byte ints; then the 2-byte shorts; then the character fields.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: