Simon Cozens wrote:
> 
> On Wed, Nov 01, 2000 at 05:35:17PM -0800, Steve Fink wrote:
> > Algorithm               Inline?         Optimization    Time (sec)
> > GOTO                    -               -O3             1.35
> > FUNCALL_HYBRID          yes             -O3             4.20
> > FUNCALL_PREDICTABLE     no              -O3             4.92
> > FUNCALL_PREDICTABLE_HALFyes             -O3             5.79
> 
> The more clever you try and be, the slower it runs?

Not really. I should have ordered things better, but it's about the
opposite. I'm not sure whether computed goto should be considered the
most or the least clever, but PREDICTABLE_HALF is just a test to see the
magnitude of the effect of removing cleverness from PREDICTABLE, and
HYBRID is if anything less clever than PREDICTABLE, because PREDICTABLE
rewrites the optree with actual pointers. So phbbbtt!! (oops, sorry).

I just did all that because the magnitude of the difference between
using separate functions and using the closer-to-assembly solutions
(switch and goto) seemed too large. I can easily believe they're faster,
but not by that much, and I didn't want to unnecessarily lose the
flexibility, readability, and compilability of keeping everything
cleanly separated out into separate functions. I've had bad experiences
with compiling enormous flex-generated switch statements -- the compiler
seems to have implicit expectations that functions won't get all that
big, so it burns a *lot* of memory and takes a very long time to compile
(I have had to change my max data size ulimit to keep it from failing).
People have had similar problems with their compilers choking on perl5's
C backend output. And keeping things as separate functions makes it
easier to do profiling & things.

Not that I'm sold on any approach yet. That's still a 3x speed drop from
computed goto, and who knows what that really means when the opcodes
start doing real work. And these are only results from a PIII. And
switches and nested else-ifs behave differently with a lot of branches.
And I had a banana sitting on my desk when I made my additions to the
benchmark, with some dark spots on the peel but not too many, and both
Ken's and my last name start with F, and... sorry, I've had a
frustrating week of performance tuning at my day job.

Reply via email to