|
Boost : |
Subject: Re: [boost] [thread] thread_specific_ptr performance
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2010-01-12 03:38:12
Andrey Semashev <andrey.semashev_at_[hidden]> writes:
> On 01/11/2010 05:22 PM, Stefan Strasser wrote:
>
>> even though I understand the need for it now, it still seems odd
>> that we use a std::map to simply access a value in another memory segment.
>>
>> have you thought about dynamically allocating an index into a
>> (thread-specific) vector instead of a key based on the thread_specific_ptr's
>> address?
>> IIUC that would allow constant-time access in all cases.
>
> Yes, that's what I did in my patch in ticket #2361. One inconvenience
> with that approach is to restrain the size of the vector if
> thread_specific_ptrs are constantly created/destroyed. I did not solve
> it in my patch but it should be quite doable.
>
> I really hope Anthony will take a look at it and come up with a
> vector-based solution. Or I can finish the patch myself, if it has any
> chance of getting into SVN. Anthony?
Boost 1.35 used a vector for the thread_specific_ptr data, but there
were complaints about the excessive memory usage. The map version has a
smaller memory footprint.
It is possible that an alternative scheme (such as using a sorted vector
as a map) might yield something that is more reasonable on both fronts.
Anthony
-- Author of C++ Concurrency in Action http://www.stdthread.co.uk/book/ just::thread C++0x thread library http://www.stdthread.co.uk Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk