This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Reduce libstdc++-v3 locale::locale() lock contention


On 12/17/2009 10:02 AM, Paolo Carlini wrote:
> Ok, I see. I was thinking that in fact, with the patch applied, people
> not actually using locales pay essentially only an atomic increment.
> Certainly we can't do better if we still want to use reference counting.
> Seems a very nice improvement a anyway.
>   
Actually, if the point is optimizing for the classic locale, which is
always a nice thing to do, then we could probably do away with reference
counting altogether: I should check, but since the locale lives in
statically allocated memory, created in it via placement new, and is
never actually destroyed, all this reference counting is rather
pointless (that reminds me the relatively recent trick we added to our
reference counted string for the trivial string consisting only of '\0',
it isn't reference counted at all, and indeed when Nathan proposed the
patch the goal was exactly reducing contention and improving performance
when different threads concurrently create default constructed strings
(*)). I don't know which are the tricky issues involved, but I'm coming
to the conclusion that for "C" we *can* do better. What do you think?

Paolo.

(*) Then in the case of basic_string this statically allocated object
creates some problems from time to time, but the issues are rather moot
because in the next ABI we will not use reference counting at all. But
the "C" locale seems a different case, because we are working under the
assumption that the actual locale is statically allocated anyway, we are
just talking about reference counting the thing or not.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]