gcd:, optimization

Daniel Vainsencher danielv at netvision.net.il
Fri Feb 20 14:57:21 UTC 1998


On Mon, 16 Feb 1998 10:18:47 -0500, David N. Smith wrote:

>At 16:13 -0500 2/14/98, Daniel Vainsencher wrote:
>>It seems to me now that the big deal in Fraction arithmetic is the
>>allocation, but I certainly wouldnt bet on it.

>From measurements in other Smalltalk systems I've found that a massive part
>of the time for Fraction operations is spent in gcd:, at least when the
>integers are quite large. The speed of large integers (of its lack) makes a
>big difference.

My initial assumption was that LargeIntegers are ignorable due to
their relative rarity. Trying to find out how unreasonable this is, I
found that two LInts are created on each change of window focus, some
thirty or so on compilation of medium-short methods and.

So I guess I was wrong. Though this still does not tell me much about
the rarity of Fractions with LInt parts, which is what concerns me
most when choosing the gcd: algorithm.

Another facet of this is that when 64-bit machines become common,
LInts will probably become significantly harder to find than now, so
it makes sense to favor SInts-friendly algorithms.

One surprising thing I did find was that quite a few LInts are
created that have lengths lower than 4, and even more that have a
length of precisely 4. A quarter of those of length 4, and all those
of lower lengths could be represented by SInts. I looked around and
did find that the system in general goes to some lengths to avoid the
creation of superflous LInts, making it even stranger. Anyone have an
explanation for this?
Would this make it worthwhile to insert another branch in
Integer>>new:neg: ?

>Dave
>
>______________________________
>David N. Smith
>IBM T J Watson Research Center
>Hawthorne, NY
>_______________________________
>Any opinions or recommendations
>herein are those of the author
>and not of his employer.
>
>

-----------
Daniel Vainsencher 
A member of the First Millennial Foundation,
making space a place to live in. Visit our CyberHabitat at
http://www.millennial.org





More information about the Squeak-dev mailing list