|
Boost : |
From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2007-08-11 14:10:24
Hi,
Lassi, thanks for filling in that detailed report.
Here are some notes to reduce the amount of wrong conclusions a reader
might jump to.
Lassi Tuura wrote:
> Hi,
>
>> It's not the first time I've seen this, and I still do not understand
>> what the belief of template meta-programming causing bloat is based
>> on.
>
> Maybe I can help with that. For simple toys and well-contained
> programs, the compiler can do a lot to inline, as was kindly shown by
> someone. But take an application of ours as an example from somewhat
> more real software world.
<... snip ...>
We should not confuse template metaprogramming with too many template
instantiations:
What's causing the bloat is multiplying code or data by instantiating
templates *not* metaprograms, since metaprograms instantiate
neither code nor data - just types. In fact, the last code sample from
the discussion with Ion presents a metaprogram to /reduce/ the bloat effect.
Redundancy reduction and even inlining can work with static linking
(given a proper linker, that is. Note GCC is rather poor when it comes
to such things, BTW). Dynamic libraries provide a barrier for these
kinds of optimizations and there's not much a C++ ABI can do about it,
as the loader is provided by the operating system (note inlining would
even require some kind of JIT compiler for the loader, BTW).
Also, dynamic libraries (which are typically overused often for the sake
of simplicity) and promote code bloat:
Unlike with static linking, dynamic libraries have to be loaded as a
whole and unused parts can't be discarded (unless via swapped out memory
pages).
Regards,
Tobias
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk