Boost logo

Boost Users :

From: Vladimir Prus (vladimir_at_[hidden])
Date: 2008-07-10 13:10:18


stefan.demharter_at_[hidden] wrote:

> I've attached 4 files. You can run ./runtest.sh in the directory to run
> the tests.

Thanks. I've reproduced this performance difference, and with the source
files at hand it's easy to see why it's there.

Try running 'nm' on your libtest.so. You'll notice that it includes
a bunch of boost::regex functions. I suspect those symbols are defined inline,
but then the compiler decides those functions are too big, and generates
out-of-line copies. Then, you're test.cpp makes a call to boost::regex function,
which in turn calls other boost::regex function. When the first call to each
function is made, dynamic linker figures out which library contains this
function.

Then system boost_regex is first on the linker line, all functions comes from
this (optimized) library. When your test.so is first, some of boost::regex
functions comes from your test.so, which is not built with optimization.

Of course, if you build your library with optimization, the performance
difference disppears.

I think this fact that mere use of a single boost::regex function cause
a bunch of implementation functions to be added to libtest.so to be unfortunate --
besides possible performance issues you've found, it also code bloat, and may
be dangerous if different versions of internal functions are included in
different libraries. Without further investigation, I don't know how easy
it is to fix.

- Volodya


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net