Boost logo

Boost :

From: Gregory Colvin (gregory.colvin_at_[hidden])
Date: 2003-05-08 12:37:07


On Thursday, May 8, 2003, at 11:07 America/Denver, Beman Dawes wrote:
> At 11:11 AM 5/8/2003, Darin Adler wrote:
>
> >On Thursday, May 8, 2003, at 07:04 AM, Beman Dawes wrote:
> >
> >> A 2-3% timing difference probably isn't reliably repeatable in real
> >> code.
> >>
> >> How code and data happens to land in hardware caches can easily
> swamp
> >> out such a small difference. The version-to-version or step-to-step
> >> differences in CPU's, memory, compilers, or operating systems can
> >> cause that much difference in a given program. Differences need to
> get
> >> up into the 20-30% range before they are likely to be reliably
> >> repeatable across different systems.
> >>
> >> At least that's been my experience.
> >
> >That has not been my recent experience. While working on my current
> >project (the Safari web browser), we have routinely made 1% speedups
> >that are measurable and have an effect across multiple machines and
> >compilers (same basic CPU type and operating system), and we have also
> >detected 1% slowdowns when we inadvertently introduced them.
>
> I notice the examples you give are JavaScript. Greg's example of a
> virtual machine is written mostly in C, IIRC. I wonder if C++ is more
> sensitive to compiler differences?
>
> For example, some C++ compilers are a lot more aggressive about
> inlining than others. For some of the code I've timed, a change slowed
> results for a compiler that failed to inline it, but ran quicker for
> the compiler that was good at inlining.

Makes sense. Boost code stresses compilers in ways that our code
doesn't -- the need to be as portable as we are means we don't
even use all the features of C89, let alone C++ or C99. And of
course C89 doesn't have things like inlining and virtual function
dispatch that can vary so much across C++ compilers. Plus we
spend a fair amount of time inspecting the output of our compilers
and tweaking our C code until we get what we want, and preserving
the tweaks in platform-specific macros.

The fact remains that it takes a lot of 3% tweaks to make a big
difference, so until you know you have the best possible data
structures and algorithms there isn't much point, and when there
is a point it is painstaking work at the limits of measurability.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk