News for hackers. Stuff that matters.
Re:When did we stop caring about memory management? by userbinator on Sunday January 10, 2016 @04:30PM (#10877291)
Align your struct members

On modern CPUs, cache misses take so long and unaligned access is nearly free in comparison, so that padding can become detrimental. Of course ordering members so that they're all aligned is the best option, but if that can't be done, it's better to have misaligned and pack more in the same space than leave wasted padding.

Re:When did we stop caring about memory management? by firethief on Sunday January 10, 2016 @06:28PM (#10877749)
The results of unaligned access can vary greatly, even among the x86 family. You can hit a large performance penalty if one of your fields straddles a cache line boundary, and $deity forbid you cross a page boundary on a Core2.

Under the right circumstances packed structs can improve performance, but they come with a lot of technical debt since they can cause sporadic extreme slowdowns on certain common CPUs, and performance problems, aborts, or even data corruption on non-x86 platforms.

Re:When did we stop caring about memory management? by poizan42 on Sunday January 10, 2016 @07:15PM (#10877925)
For x86, sure. For other architectures you end up with larger code size for unaligned access, so it also becomes a tradeof between code/instruction and data cache usage.