This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] PR libstdc++/71312 Increase alignment of pooled mutexes
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: François Dumont <frs dot dumont at gmail dot com>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Thu, 2 May 2019 20:56:24 +0100
- Subject: Re: [PATCH] PR libstdc++/71312 Increase alignment of pooled mutexes
- References: <20190429125525.GA29417@redhat.com> <244fc80e-663c-5ec0-8f12-373649f36da0@gmail.com>
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.