[C++-sig] Profiling object instantiation... a preliminary report

Greg Landrum greglandrum at earthlink.net
Thu Mar 7 04:50:18 CET 2002


Re-establishing context:
I have an extension class that I've wrapped using both Boost and Cxx.  I 
need to be able to pickle and depickle large numbers (1e5-1e6) of these 
objects quickly for my target application (storing them in a ZODB and 
querying the resulting database).  I discovered that simple instantiation 
of 1e5 objects took dramatically longer in Boost than in Cxx (6.7 seconds 
vs 0.9 seconds).

I pulled down a copy of Intel's vtune profiler[1] and profiled my Boost and 
Cxx wrapped libraries to find the origin of the huge performance 
difference.  After fiddling around for a while figuring out the appropriate 
magic to make vtune actually work, I found something surprising.

I had exposed 4 different constructors for my Mol class.  What I failed to 
realize is that when you overload functions (at least constructors) in BPL, 
this is handled using exceptions.   This was at least partially responsible 
for the tremendous slow down in the Boost wrapper of my code.  When I 
commented out some constructors, rebuilt, and reprofiled my code I got a 
run time of 1.9 seconds, only twice the Cxx run time.  I'm a lot happier 
with this, but I'll continue to do a bit of exploration to see if I can 
bring that down more.  I'm rather enjoying vtune now that I've figure out 
what can be done with it.

If anyone wants more detailed information, I'd be happy to provide it.

-greg
[1] The beta of vtune is available as a free download for linux and 
windows.  These results are under Win2K using MSVC++ v6.
----
greg Landrum (greglandrum at earthlink.net)
Software Carpenter/Computational Chemist





More information about the Cplusplus-sig mailing list