Boost logo

Boost :

Subject: [boost] [thread] thread_specific_ptr performance (was: Re: Boost library submission (poll for interest))
From: Stefan Strasser (strasser_at_[hidden])
Date: 2010-01-08 13:37:37

Am Friday 08 January 2010 16:39:27 schrieb Rutger ter Borg:
> 1) Transactional semantics: wouldn't it be easier to steal semantics from
> locks in threads? E.g., for the synchronous interface case, wouldn't
> map_type m_map;
> try {
> scoped_transaction trans( m_map );
> ..
> .. do stuff with the map
> ..
> trans.commit();
> }
> catch( transaction_error ) {
> }
> be a easier than passing the transaction everywhere?

implementing this requires a call to thread_specific_ptr::get() on each
operation to obtain the active transaction.

unfortunately thread_specific_ptr is implemented using pthread calls and a
std::map lookup, so this consumes > 6% CPU in one of my test cases.
and this is a real world test case with other expensive stuff, in cases that
e.g. only read cached objects it's probably even worse.

is there any chance for a thread_specific_ptr implementation based on GCC
__thread and MSVC __declspec(thread)?

__thread results in a simple read access using a thread-specific memory

Boost list run by bdawes at, gregod at, cpdaniel at, john at