From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-06-30 04:44:17
I've became interested in how efficient code-size-wise boost::function is, so
I wrote a small script which generates a function which calls boost::function
object N times and finds the size of the generated function.
The results are somewhat interesting and somewhat alarming (to me).
On gcc 3.3 with -Os, each call to boost::function costs 147 bytes of code
size. With -O3 it's about 166 bytes.
On gcc 3.4 calls cost 203 bytes with -Os and between 220 and 240 with -O3.
However, when boost::function is called 15 times, the inliner heuristics kick
in and calls are no longer inlined -- meaning each call costs about 14 bytes.
This is a good thing for 3.4, but still:
1. For 3.3 boost::function causes a serious code bloat.
2. Even for 3.4, I'm not sure how it will perform if calls are done in several
modules. Or how the heuristics will work on non-trivial cases: if they use
the % of size increase then on large modules boost::function inlining can
cost much more.
Given that, IIUC, boost::function has to do indirect call somewhere anyway,
I'm not sure inlining is such a good idea. Maybe some of the methods should
be declared out-of-line, so that compiler don't try to inline them?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk