TECH Signal 243 2 feeds carried it
Spin-lock optimization achieves 5.7x speedup and 5.4x energy reduction
A step-by-step spin-lock optimization reduces latency by 5.7x and energy draw by 5.4x through memory ordering and test-and-test-and-set techniques.
Spin-locks are used in high-performance concurrency where sleeping is too costly. Reducing energy draw matters for colocation services that charge for power, and lower latency improves throughput. The techniques shown, using acquire/release ordering and read-only spinning, are directly applicable to any lock implementation.
Written by elseif from the cluster below · every claim links back to a sourceThe three things worth knowing
The naive exchange-based spin-lock takes 246 ns with four threads and draws 64.92 J.
Switching to acquire/release memory ordering halves uncontended latency to 1.57 ns and cuts four-thread latency to 131 ns.
Adding a read-only spin with _mm_pause reduces two-thread latency from 32.5 ns to 21.3 ns.
THE CLUSTER
↗