cpp0 performance regressions
Neil Booth
NeilB@earthling.net
Sat Nov 4 07:04:00 GMT 2000
Currently, cpp0 is kinda slow, to say the least. There are 2
important reasons for this:
a) The way we use stdio (at least glibc's stdio) for output is a
complete performance killer. I have reason to believe that just
output is taking over 70% (!!) of time in the objlike-test.c benchmark
below.
b) Function-like macro expanding has had no attempt at optimisation;
it should be possible to speed this up a lot.
For integrated CPP a) is obviously completely removed; b) remains.
These effects show up impressively in the benchmarks below. Each
timing is in seconds, and is an average of 5 runs after an initial
cache priming run. The timings in each set of 5 differ negligibly.
Timings are on an AMD K6-2 350 Mhz under Linux.
Test Current cpp0 2.95.2 %
---- ------------ ------ -
objlike-test.c 2.968 1.421 209%
stpcpy-test.c 4.752 1.861 255%
combine.c 0.625 0.403 155%
insn-attrtab.c 0.994 0.402 247%
Objlike-test.c just does lots of object-like macro expansions;
stpcpy-test.c a highly nested function-like macro expansion using
glibc string macros nested 4 deep, about 30 times. Both of these
result in literally hundreds of thousands, if not millions, of tokens
to output, completely killing cpp0.
The last two use the invocations of cpp0 on a bootstrap of CVS GCC for
a more all-round test.
I'm going to work on a) and b) now, and my aim in the next few weeks
is to bring cpp0 more on par to 2.95.2. I hope to beat 2.95.2 in at
least 2 of the above benchmarks; and maybe all eventually. Just
fixing the output slowness will improve the comparison a lot.
Neil.
[Incidentally, the tests aren't entirely fair. We've introduced new
functionality like _Pragma, which cpp0 needs to test for on each
identifier being passed through to output. 2.95.2 does not have this
overhead. It also has a macro expansion bug. Moreover, we have
disallowed cpp0 the advantage of being able to jump around in the
input stream, which 2.95.2 does to abandon, as a move towards
multibyte char support.]
More information about the Gcc
mailing list