This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [Patch (preview)] libstdc++/24469
- From: Paolo Carlini <pcarlini at suse dot de>
- To: Paolo Carlini <pcarlini at suse dot de>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>, Richard Guenther <rguenther at suse dot de>
- Date: Fri, 01 Sep 2006 05:42:24 +0200
- Subject: Re: [Patch (preview)] libstdc++/24469
- References: <44F78DB9.9080000@suse.de>
Paolo Carlini wrote:
I think everything is fine... Otherwise, please stop me before it's
too late! :)
Well, I can see a serious problem myself but it's fixable ;)
In a pure producer/consumer scheme, for example, some threads only
allocate and some, different, threads only deallocate, thus _M_used of
the allocating threads can easily overflow, especially so the atomic
counters, which are only 32-bits wide. The solution, simple, is
resyncing _M_used of each thread to its reclaimed counterpart at the
beginning of both _M_reclaim_block and _M_reserve_block (the fast
allocations, using _M_adjust_freelist are not affected and the binary
compatibility still safe). In order not to affect the performance we can
do that every fixed number of allocations and deallocations, say 1 << 12
or something, and easily amortize the atomic... Will do tomorrow....
Paolo.