Discussion:
[Larceny-users] running fasl's
Marijn Schouten (hkBst)
2009-03-09 12:56:01 UTC
Permalink
Hi,

I have some Scheme code that I'd like to run (pre-)compiled, but I'm probably
doing something wrong because I'm not seeing any speed increase in comparison to
simply running it.

To run the code I always use:

$ larceny -- -e "(require 'srfi-0)" ising.scm -e "(time (main 100))" -e "(quit)"

to compile the code I use:

$ larceny -- -e '(compile-file "ising.scm")' -e "(quit)"

which produces the file ising.fasl. I try to run the code with and without the
fasl existing, but in both cases it takes the same number of seconds to run.

The code is basically
http://dynamo.iro.umontreal.ca/~gambit/wiki/images/0/0d/Ising-20090308.scm

Marijn

- --
Sarcasm puts the iron in irony, cynicism the steel.

Marijn Schouten (hkBst), Gentoo Lisp project, Gentoo ML
<http://www.gentoo.org/proj/en/lisp/>, #gentoo-{lisp,ml} on FreeNode
William D Clinger
2009-03-09 13:35:04 UTC
Permalink
Post by Marijn Schouten (hkBst)
I have some Scheme code that I'd like to run (pre-)compiled,
but I'm probably doing something wrong because I'm not seeing
any speed increase in comparison to simply running it.
You are probably using the IA32-native version of Larceny,
which automatically compiles everything you run, load, or
type. Pre-compiling eliminates the compile time, but the
run time will be exactly the same.
Post by Marijn Schouten (hkBst)
The code is basically
http://dynamo.iro.umontreal.ca/~gambit/wiki/images/0/0d/Ising-20090308.scm
If the code is too slow, it's probably because Larceny's
implementation of SRFI 19's random-integer is slow. If
you don't need high-quality random numbers, then you
could use a faster implementation of random-integer.
Larceny's implementation of random-real is probably fast
enough, especially if you're using the current development
system. (I improved Larceny's implementation of SRFI 19
just a few days ago.)

Will
William D Clinger
2009-03-10 00:29:08 UTC
Permalink
In my previous message, I said "SRFI 19" twice when I meant
"SRFI 27". (I modified Larceny's implementations of both
SRFIs within the last few days, and got them confused.)

Will
William D Clinger
2009-03-10 01:46:36 UTC
Permalink
As of revision:6120, Larceny's implementation of random-integer
from SRFI 27 is considerably faster than before. If that has
been holding you back, you might want to replace the old versions
of lib/SRFI/srfi-27.sch and lib/SRFI/srfi/%3a27.sls with the new
ones relative to

https://trac.ccs.neu.edu/trac/larceny/browser/trunk/larceny_src/

Will
Marijn Schouten (hkBst)
2009-03-10 10:31:47 UTC
Permalink
Post by William D Clinger
As of revision:6120, Larceny's implementation of random-integer
from SRFI 27 is considerably faster than before. If that has
been holding you back, you might want to replace the old versions
of lib/SRFI/srfi-27.sch and lib/SRFI/srfi/%3a27.sls with the new
ones relative to
https://trac.ccs.neu.edu/trac/larceny/browser/trunk/larceny_src/
Will
Thanks Will,

I will try to test it soon. Maybe now larceny is faster than the gambit
interpreter ;P

Marijn

- --
Sarcasm puts the iron in irony, cynicism the steel.

Marijn Schouten (hkBst), Gentoo Lisp project, Gentoo ML
<http://www.gentoo.org/proj/en/lisp/>, #gentoo-{lisp,ml} on FreeNode
Marijn Schouten (hkBst)
2009-03-13 15:11:24 UTC
Permalink
Post by William D Clinger
As of revision:6120, Larceny's implementation of random-integer
from SRFI 27 is considerably faster than before. If that has
been holding you back, you might want to replace the old versions
of lib/SRFI/srfi-27.sch and lib/SRFI/srfi/%3a27.sls with the new
ones relative to
https://trac.ccs.neu.edu/trac/larceny/browser/trunk/larceny_src/
Will
Hi Will,

as mentioned in my mail about the versions I just installed from the svn repo.
Performance improved dramatically. For a version of my program which is more
intensive in random-real than in random-integer results went from

Words allocated: 2881397657


Words reclaimed: 0


Elapsed time...: 48662 ms (User: 48628 ms; System: 25 ms)


Elapsed GC time: 751 ms (CPU: 707 in 10994 collections.)

to

Words allocated: 2802698351
Words reclaimed: 0
Elapsed time...: 30554 ms (User: 29516 ms; System: 187 ms)
Elapsed GC time: 162 ms (CPU: 141 in 2673 collections.)

which is a great improvement, so thank you.

For comparison, gambit compiled currently does

9579 ms real time


8696 ms cpu time (8686 user, 10 system)


3704 collections accounting for 1383 ms real time (1368 user, 0 system)


2864853696 bytes allocated


325 minor faults


no major faults

for the same run (1000 cluster flips per site with the Wolff algorithm on a
40x40 grid).

Marijn

- --
Gods do not want you to think, lest they lose existence.
Religions do not want you to think, lest they lose power.

Marijn Schouten (hkBst), Gentoo Lisp project, Gentoo ML
<http://www.gentoo.org/proj/en/lisp/>, #gentoo-{lisp,ml} on FreeNode
William D Clinger
2009-03-13 15:27:40 UTC
Permalink
Marijn reported that Gambit is about 3 times as fast as
the current development version of Larceny "for the same
run (1000 cluster flips per site with the Wolff algorithm
on a 40x40 grid)."

In general, Gambit should be about 3 times as fast as
Larceny on floating point computations. The reason is
that Gambit's compiler tries to generate code for unboxed
flonums. Larceny does not yet do that, and the cost of
boxing every flonum turns out to be a factor of 3 on IA32
machines.

Before v0.97a4, Larceny had some additional inefficiency
caused by two longjmp operations on the millicode path
used by mixed-mode arithmetic and by a few operations such
as inexact->exact. Removing those longjmp operations made
that millicode path over 10 times as fast.

Will

Continue reading on narkive:
Loading...