Boost logo

Threads-Devel :

Subject: Re: [Threads-devel] basic_timed_mutex poor performance
From: Anthony Williams (anthony_at_[hidden])
Date: 2009-03-30 04:03:10

At Mon 30 Mar 2009 08:43:54 BST, Simon Brangwin <simon_at_[hidden]> wrote:

> The basic_timed_mutex seems to do an awful lot of working in its
> constructor, calling various Gregorian date functions, calendar
> functions, xtime functions doing comparisons etc. This has lead to an
> approximate 5% performance loss for our performance sensitive
> application on the Win32 platform.

Wow, that's huge.

> Is there a way to disable this heavy weight basic_timed_mutex, and use a
> plain old regular mutex ? Are the Boost Threads library maintainers
> aware of the performance penalties from using timed mutex for Windows
> platforms?

The boost 1.35 mutex performance was indeed poor on win32, but this
did not seem to be due to the date-time dependencies, but due to the
inefficient use of atomics. The current (1.38) version of the win32
mutex is comparable or faster than the 1.34 mutex according to my
benchmarks. I can't remember whether the change made it in to 1.36 or
whether it had to wait for 1.37.

There may however be a further small gain to be made by stripping out
the timing stuff from the non-timed mutex, but there is currently no
way to do this without hacking the code.


Anthony Williams
Author of C++ Concurrency in Action |
just::thread C++0x thread library   |
Custom Software Development         |
Just Software Solutions Ltd, Registered in England, Company Number 5478976.
Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK

Threads-Devel list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at