News for hackers. Stuff that matters.
Re:Padding is hard by adonovan on Friday October 09, 2015 @12:17PM (#10361093)
The most compact representation is not always the most efficient. If two fields in the same struct variable are accessed by different goroutines, placing them far apart so that they reside in different cache lines may avoid a great deal of contention.
Re:Padding is hard by masklinn on Friday October 09, 2015 @12:36PM (#10361268)
Except technically struct memory layout is currently undefined in Go so you're relying on an implementation detail.
Re:Padding is hard by adonovan on Friday October 09, 2015 @12:53PM (#10361456)
This kind of optimized placement could in principle be done by a sufficiently smart compiler, but no such compiler exists. That's why existing compilers allow their users to control layout by, as you say, relying on an implementation detail.
Re:Padding is hard by masklinn on Friday October 09, 2015 @01:05PM (#10361565)
No, the language can specify source—order struct layout, either by default or opt-in.