Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!nntp.sei.cmu.edu!news.psc.edu!hudson.lm.com!godot.cc.duq.edu!news.duke.edu!news.mathworks.com!tank.news.pipex.net!pipex!howland.reston.ans.net!torn!nott!cunews!tina.mrco.carleton.ca!knight
From: knight@mrco.carleton.ca (Alan Knight)
Subject: Re: That 15,000:1 speedup: how real? [code included]
X-Nntp-Posting-Host: tina.mrco.carleton.ca
Message-ID: <knight.810917270@tina.mrco.carleton.ca>
Sender: news@cunews.carleton.ca (News Administrator)
Reply-To: knight@mrco.carleton.ca (Alan Knight)
Organization: The Object People
References: <DEDsF1.3I8@cunews.carleton.ca> <42fthj$95e@news.iastate.edu> <knight.810307251@tina.mrco.carleton.ca> <42mvrt$13hr@watnews1.watson.ibm.com> <42sn4h$a1q@news.iastate.edu>
Date: Tue, 12 Sep 1995 14:47:50 GMT
Lines: 54

In <42sn4h$a1q@news.iastate.edu> rhawkins@iastate.edu (Rick Hawkins) writes:

>>   >The speedup was 15,000:1.

>I switched the code from integer to floating point in the smalltalk
>version before the whole thing was running.  (also before i found quo:
>and //, i think).  The alpha can supposedly do a floating point faster
>than two integers.

But probably not in Smalltalk. Most Smalltalks have heavily optimized
integer arithmetic, but don't pay much attention to floating point,
since it isn't heavily used in their target markets.

>Also, I seem to have divided incorrectly :).  Each job was killed upon
>hitting one hour of CPU time (by the OS).  The smalltalk version stepped
>through 160 days; the Fortran through a quarter million.  This seems to
>be 1,500, not 15,000.  oops :)

Makes a bit of a difference...

>What is frequently happening is that smalltalke must make multiple
>function callse, while fortran need only 

Yes, this clearly makes a difference. In FORTRAN it is often possible
to make very very few function calls and to write everything as access
to static arrays. This will clearly have an advantage over Smalltalk,
where function calls are used for almost everything and array access
has the overhead of bounds checking. How much this overhead costs
depends on the program. I might believe a factor of 100-200 for a
really severe case, which this sounds like. I've dealt with FORTRAN
programs written like this, and I pity the person who has to maintain
it (at least you write comments, which never seemed to be part of the
FORTRAN culture when I was doing it).

>I suppose i could have implemented my entire data structure as a global
>wordarray in smalltalk (though, using gnu, i would have had to write the
>class,

Aha! You didn't mention that you were using GNU Smalltalk. It's been
known to have, um, suboptimal performance. In fact this is rather like
saying how much faster Smalltalk runs than C when I do the C
benchmarks on a Z-80 by compiling them into Prolog. 

So the factor of 15,000 is actually 1,500, it turns out to be using a
very slow Smalltalk implementation, and floating-point calculations
rather than integers. I haven't looked at the code for other possible
inefficiencies, but this is starting to sound more reasonable.


-- 
 Alan Knight                | The Object People
 knight@acm.org             | Smalltalk and OO Training and Consulting
 alan_knight@mindlink.bc.ca | 509-885 Meadowlands Dr.
 +1 613 225 8812            | Ottawa, Canada, K2C 3N2
