From: ·····@bbn.com
Subject: RE: war stories.
Date: 
Message-ID: <mp3dk9INNk0u@news.bbn.com>
since Ken thinks it's important to share these things:

from ~1989:

i was working with a chunk of code which does polygon algebra (that
means exactly what you think it does). it was all written in CLOS, a
very strange algorithm which I never did fully understand. everything in
it was a CLOS instance--everything, even an x,y pair. so getting the x
and y values of a point involved method dispatches, and when working
with polys, you do a lot of point access.

changing the point to be a cons and the accessors to macros brought a 3X
speedup for about 5 minutes work.

a rework or the line-intersection algorithm was another 2X speedup.

the point being: the code was grossly overdesigned. there didn't really
need to be quite so many classes or instances everywhere.



from ~1988:

I had a function which computed something about 3D intervisibility, in
some hack of a ray-tracing fn. lotta transcendentals in there, which I
was computing more than once. after doing performance metering, I
isolated this fn, and rewrote to only compute values once.
transcendentals are not cheap even under the best circumstances (well,
they can be, but it takes special hardware, because you precompute
everything and then pump the values into ROMs and just do hardware-level
table-lookup), so you don't want to compute them more than necessary.

that was worth a 3X speedup.

I can't remember exactly how much DECLARE'ing I did with these things.



final lesson: know which things are expensive, and avoid them.
unfortunately, they're both machine and compiler-dependent. bummer. it
takes a while to learn them.

 -- clint