help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Disable STL thread locking


From: David Coppit
Subject: Disable STL thread locking
Date: 17 Mar 2005 08:40:06 EST

Greetings all,

I'm trying to optimize some code generated by g++ 3.3 on powerpc (Mac).
I'm using Apple excellent Shark tool to analyze my code, and it says that
15% of my time is spent in libSystem.B.dylib, in two functions:
pthread_mutex_lock and pthread_mutex_unlock.

I assume this is data structure locking for STL. Since my application is
single threaded, I was wondering if there was some way to disable locking
and therefore avoid this 15% overhead.

I tried the sledgehammer method, which is to change

      typedef __alloc _Alloc;          // The underlying allocator.

to

      typedef __single_client_alloc _Alloc; // The underlying allocator.

in stl_alloc.h, but this didn't seem to work. (Plus I'd like a solution
that's more compiler independent.) Adding an allocator parameter to every
STL data structure in my program is also a real pain.

Can anyone help out?

Thanks,
David


reply via email to

[Prev in Thread] Current Thread [Next in Thread]