Re:Recursive (Re-Entrant) Locks (2013)
by hinkley on Saturday February 18, 2023 @01:58PM
(#34849876)
The concurrent queue code in Java has/had an array the locks were placed in. Now the problem with putting locks in arrays instead of scattering them across the heap is that you get false sharing immediately. So the array is 8 or 16 times as big as it needs to be to get one lock per cache line.
[ Parent
| on HN ]
Re:Recursive (Re-Entrant) Locks (2013)
by charleslmunger on Saturday February 18, 2023 @02:25PM
(#34850153)
The @Contended annotation will pad the memory layout of fields to fill a cache line and avoid false sharing.