3 ms·
Look up “false sharing”, the situation where two goroutines that access disjoint sets of fields contend for the same cache line. Compilers are not smart enough
by adonovan 5y ago
Look up “false sharing”, the situation where two goroutines that access disjoint sets of fields contend for the same cache line.
Compilers are not smart enough to detect it, but if they lay out struct fields in declaration order, the programmer has a way to avoid the problem: by putting the two threads’ fields far apart.
- berkut 5y agoYeah, quite often in HPC you very much do want to be able to control the alignment and packing (even though it's annoying to do), because you'll get caching issues otherwise, depending on the access patterns and size of the data.
- tjoff 5y agoIt seems to follow that you shouldn't use Go in HPC. Which is also fine.