Golang & Concurrency (50 Qs)•Part 4: Production Compilation, Tooling & Senior Engineering (39 - 50)
Concurrency Pitfall: Memory Model Synchronization and False Sharing.
senior LevelgolangProduction Compilation
In Simple Words:
False Sharing: When two goroutines running on different CPU cores modify independent variables that happen to sit on the same 64-byte CPU cache line, the CPU cores continuously invalidate each other's L1/L2 caches.
Fix: Add cache line padding ([64]byte) between hot fields.