c++ with pthread?
s_sourceforge at nedprod.com
Tue Nov 8 01:47:30 PST 2005
On 8 Nov 2005 at 8:06, Norbert Koch wrote:
> > Thanks for your reply!
> > Performance wise, would you think commoncpp is better with threads than
> > directly pthread?
> > Nicolas.
> Commoncpp tries to be platform-independent. So, no.
> What performance are you talking about? Thread creation
> may be slower, but context changes are always handled by
> pthread. So there would be no difference.
> Mutexes and conditionals will be slower too.
> I never ran any benchmarks.
The implementation of mutexes is the single biggest determinant of
heavily multithreaded code. FreeBSD has a very simple memory
allocator which always serialises to one thread, resulting in VERY
poor performance when you have three or more threads running at once.
TnFOX has its own memory allocator (ptmalloc2) as well as its own
mutex implementation. I haven't found any system (win32, win64, linux
or freebsd) whose native facilities come anywhere close to TnFOX's
In other words, choosing a good optimised threading library makes ALL
the difference to performance.
I once again strongly suggest that the FreeBSD memory allocator in
libc is replaced with ptmalloc2
(http://www.nedprod.com/programs/Win32/ptmalloc2/ - its MIT licence).
Doing this gives a several fold speed increase even in single
threaded C++ apps due to the fastbins.
More information about the freebsd-threads