[PATCH] PR libstdc++/71312 Increase alignment of pooled mutexes

Jonathan Wakely jwakely@redhat.com
Thu May 2 19:56:00 GMT 2019


On 02/05/19 21:43 +0200, François Dumont wrote:
>I am surprised that 64 bytes is not more platform dependent. Is it a 
>convention that 64 is greater or equal to the largest cache line known 
>so far ?

Prove me wrong  ;-)

It's correct for the majority of common hardware. And even on a CPU
with 128 (or larger) cache lines, padding the mutexes reduces the
number that will share a cache line, so reduces false sharing.

So this is optimal on most machines, and better than what we had
before on the rest.

In a perfect world we'd use
std::hardware_destructive_interference_size but we haven't implemented
that yet, for reasons.


>François
>
>On 4/29/19 2:55 PM, Jonathan Wakely wrote:
>>    PR libstdc++/71312
>>    * src/c++11/shared_ptr.cc (get_mutex): Align pool mutexes to 64 
>>bytes.
>>
>>Tested powerpc64le-linux, committed to trunk.
>>
>



More information about the Libstdc++ mailing list