Boost logo

Boost Users :

Subject: Re: [Boost-users] Thread local storage
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2009-03-30 03:47:58

Thanks for alerting me to this thread Peter.

Oliver Abert <abert_at_[hidden]> writes:

> On 29.03.2009, at 19:36, Peter Dimov wrote:
>> Oliver Abert:
>>> Hi Everyone,
>>> I am using Boost Threads (1.38) as threading library and I also use
>>> the thread_specific_ptr to store a minor amount of data per thread
>>> (I think currently it is like 5 different pointer values per
>>> thread). Technically everything works out fine, but I am having a
>>> performance problem on Mac OS X. On Linux the performance is 10
>>> times faster than on Mac OS. If I use pthreads on Mac OS I have
>>> identical performance to the Linux version. Both versions are
>>> running on the same machine using 8 threads both.
>> What does your profiler say?
> about 80% of the time is spend in __spin_lock which in turnwas called
> by pthread_once. If I use only one thread (instead of 8) the
> percantage goes down to 2.5% - which is still a bit much for my taste.

pthread_once is called by the thread_specific_ptr code to ensure that
the TLS key it uses has been allocated and is valid. It's a real pain if
that is too slow.


Author of C++ Concurrency in Action |
just::thread C++0x thread library   |
Just Software Solutions Ltd         |
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at