[Python-Dev] Dictionary sparseness

Alex Martelli aleax@aleax.it
Mon, 5 May 2003 19:22:53 +0200


On Monday 05 May 2003 06:47 pm, Guido van Rossum wrote:
> > I used madvise extensively (and quite successfully) back when I was
> > the senior software consultant responsible for the lower-levels of a
> > variety of Unix-system ports of a line of mechanical CAD products.
> > And I loved and still love the general concept -- let me advise an
> > optimizer (so it can do whatever -- be it a little or a lot --
> > rather than spend energy trying to guess what in blazes I may be
> > doing:-).
>
> Hm.  How do you know that you were succesful?  I could think of an

By measuring applications' performance on important benchmarks (mostly
not artificial ones, but rather actual benchmarks used in the past by some
customers to help them choose which CAD package to buy -- we treasured
those, at that firm, and had built up quite a portfolio of them over the 
years).  As CPUs and floating-point units became fast enough, more and
more of the speed issues with so-called "CPU intensive" bottlenecks in
mechanical-engineering CAD actually became related to memory-access
patterns (a phenomenon I had already observed when I worked on IBM
multi-CPU mainframes with vector-units, being sold as "supercomputers" 
but in fact still having complex and deep memory hierarchies -- Cray guys
of the time such as Tim no doubt had it easier!-).

> implementation that's similar to those "press to cross" buttons you
> see at some intersections, and which seem to have no effect whatsoever
> on the traffic lights. :-)

Yes, there were a few of those, too.  That's part of what's cool about
an "advise" operation: it IS quite OK to implement it as a no-op, both in
the early times when you're moving an existing API to some new
platform, AND in (hypothetical:-) late maturity when your optimizer's
pattern-detector has become able to outsmart the programmer on a
regular basis.  C's "register" keyword is a familiar example: it was quite
precious in very early compilers with nearly nonexistent optimizers, it
was regularly ignored in new compilers for very limited (and particularly
register-limited) platforms, and it's invariably ignored now that optimizers
have become able to allocate registers better than most programmers.
(It should probably have been a #pragma rather than eat up a reserved
word, but that's just syntactic-level hindsight:-).


Alex