This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [libstdc++ PATCH/RFC] Aggressive space optimization for std::vector
On Tue, Jul 29, 2003 at 06:35:31AM +0200, Gabriel Dos Reis wrote:
> Doug Gregor <dgregor@apple.com> writes:
>
> | I don't know, but I do know we can do a pretty
> | good job at the library level, and we can have it now on all platforms.
>
> I'm not convinced this is an absolute win. Thta is a tradeoff.
> You're optimizing for space at the library level. It is important to
> know the effect on speed. Optimizing for space tends to have a
> negative effect on speed.
Maybe it's just my limited imagination, but I can't imagine how
eliminating extra copies of identical functions, so that only one
copy takes up space in cache, could possibly slow things down. It
looks to me, instead, as if reducing cache pressure would have to
speed things up, in real programs that do experience cache pressure.
Maybe 25 kbytes doesn't amount to much these days when measured
against the many megabytes of libraries we use, but it's a big
percentage of a typical L2 cache, and about the same as a typical
L1 cache. If the extra code did anything for us (e.g. unrolled
loops that save branch points) it might be worth keeping, but it
looks to me like pure waste.
So, to me the question is purely one of whether the space and time
savings is worth the extra complexity. In an individual program,
probably not. Amortized over the thousands of programs and libraries
that will use libstdc++ on millions of machines, most likely so.
Therefore, we do need for this to be a very clean patch to minimize
the complexity it adds. (Besides maintenance cost, compile times
haven't been going down lately.)
Nathan Myers
ncm-nospam@cantrip.org