Re:Padding is hard
by neilc on Friday October 09, 2015 @12:39PM
(#10361307)
> why the compiler shouldn't reorder structs so that they take the least space possible
I think you'd get most of the benefit by writing a static analysis tool (a la "go vet") that suggests when reordering a struct's fields would reduce memory consumption.
Re:Padding is hard
by masklinn on Friday October 09, 2015 @02:00PM
(#10362097)
Except Go doesn't guarantee source-order struct layout, so that'd be a suggestion relying on implementation details (see also: relying on scheduling order of goroutines).
I think you'd get most of the benefit by writing a static analysis tool (a la "go vet") that suggests when reordering a struct's fields would reduce memory consumption.