News for hackers. Stuff that matters.
Re:The Lost Art of C Structure Packing by icedog on Friday February 20, 2015 @08:36PM (#9084291)
I'm not saying it's exactly the knapsack problem, but it's quite related. Ordering from largest to smallest does not yield the optimal solution - period.
Re:The Lost Art of C Structure Packing by ruggeri on Saturday February 21, 2015 @10:14PM (#9088048)
The article says throughout that sorting the fields in order of decreasing alignment requirement (i.e., size) minimizes slop. The proof for this is pretty straightforward. The article also discusses why you might not do this (e.g., structures might try to match layout of memory mapped devices).

Rudeness is a choice you make, by the way. You can change your behavior.