[Python-Dev] insertdict slower?

Tim Peters tim.one@home.com
Fri, 2 Feb 2001 02:34:07 -0500


[Jeremy]
> I was curious about what the DictCreation microbenchmark in
> pybench was slower (about 15%) with 2.1 than with 2.0.  I ran
> both with profiling enabled (-pg, no -O) and see that insertdict
> is a fair bit slower in 2.1.  Anyone with dict implementation
> expertise want to hazard a guess about this?

You don't need to be an expert for this one:  just look at the code!
There's nothing to it, and not even a comment has changed in insertdict
since 2.0.  I don't believe the profile.

There are plenty of other things to be suspicious about too (e.g., it showed
285 calls to eval_code2 in 2.0, but 998 in 2.1).

So you're looking at a buggy profiler, a buggy profiling procedure, or a
Cache Mystery (the catch-all excuse for anything that's incomprehensible
without HW-level monitoring tools).  WRT the latter, try inserting a renamed
copy of insertdict before and after the existing one, and make them extern
to discourage the compiler+linker from throwing them away.  If the slowdown
goes away, you're probably looking at an i-cache conflict accident.