Discussion:
[Larceny-users] fixnum math
Ray Racine
2008-09-21 22:40:12 UTC
Permalink
fx math is unexpectedly slower.

(define times 100000000)

'std-math

(time
(let ((v (make-vector 2)))
(vector-set! v 1 2)
(do ((n times (- n 1)))
((zero? n) (vector-ref v 1))
(vector-ref v 1))))

'fx-math

(time
(let ((v (make-vector 2)))
(vector-set! v 1 2)
(do ((n times (fx- n 1)))
((fxzero? n) (vector-ref v 1))
(vector-ref v 1))))
William D Clinger
2008-09-22 17:34:55 UTC
Permalink
Post by Ray Racine
fx math is unexpectedly slower.
Yes. This is mentioned in the note at the end of
Larceny User Manual section 8.11 [1].

Larceny's GreatPrimOpCleanUp [2] will improve matters
by making the R6RS fx operations run at the same speed
as the generic operations, but the R6RS fx operations
will never be any faster than the generic operations
in Larceny because the R6RS requires all fx operations
to check their arguments and also their result.

At one point, the R6RS editors intended to provide
an unsafe mode in which the R6RS fx operations might
be faster than the generic operations, but unsafe fx
operations were removed from the draft R6RS at the
insistence of at least two discussants, one of whom
was Aziz Ghuloum. The idea that fx operations should
be faster than generic operations still persists, but
that idea is not consistent with the R6RS as ratified.

Larceny may eventually provide a Larceny-specific
library that exports Larceny-specific versions of
the R6RS fx operations that run faster than the
generic operations. The Larceny-specific versions
would be unsafe in the R6RS sense, because they
would be incompatible with the R6RS operations,
but they would be safe in the traditional sense
of the word "safe".

Will

[1] http://larceny.ccs.neu.edu/doc/user-manual-alt.html#R6rsArithmeticSection
[2] https://trac.ccs.neu.edu/trac/larceny/wiki/GreatPrimOpCleanUp
David Rush
2008-09-22 22:02:58 UTC
Permalink
Post by William D Clinger
Post by Ray Racine
fx math is unexpectedly slower.
the R6RS fx operations
will never be any faster than the generic operations
in Larceny because the R6RS requires all fx operations
to check their arguments and also their result.
...
Post by William D Clinger
unsafe fx
operations were removed from the draft R6RS at the
insistence of at least two discussants, one of whom
was Aziz Ghuloum
<claws mode="out">
So are they faster in ikarus?
<claws mode="retract">
Post by William D Clinger
Larceny may eventually provide a Larceny-specific
library that exports Larceny-specific versions of
the R6RS fx operations that run faster than the
generic operations.
Please do. Performance has always been one of my motivations to use
Larceny and right now I am looking at it to bootstrap a numerical
programming platform. an 'unsafe' mode with all the explicitly typed
primitives exposed would be really great :)

david rush
--
GPG Public key at http://cyber-rush.org/drr/gpg-public-key.txt
Loading...