News for hackers. Stuff that matters.
Re:Ditch your (mut)ex, you deserve better by gpderetta on Tuesday November 18, 2025 @07:47AM (#45964970)
The issue might be allocating the int contiguously in the first place. No language magic is going to help you avoid thinking about mechanical sympathy.

And allocating the int contiguously might actually be the right solution is the cost of sporadic false sharing is less than the cost of wasting memory.

There's no silver bullet.

Re:Ditch your (mut)ex, you deserve better by magicalhippo on Tuesday November 18, 2025 @07:50AM (#45965007)
But the mutex encapsulates the int, so if the mutex ensured it occupied a multiple of cache lines, there would be no contention. At the very small cost of a few bytes of memory.
Re:Ditch your (mut)ex, you deserve better by gpderetta on Tuesday November 18, 2025 @07:54AM (#45965054)
the mutex forcing alignment would be extremely wasteful. FWIW, I have used 1-bit spin locks.