Everything Else

about LISP performance - Page 1

Hi LISP gurus :)

Was playing with Lisp on my WinXP and was wondering why this large difference of performance.

I got GNU Emacs and CLISP on my WinXP laptop. I run these following codes respectively:

Code:
(defun silly-loop (n)
"Return the time, in seconds, to run N iterations of a loop."
(let ((t1 (float-time)))
(while (> (setq n (1- n)) 0))
(- (float-time) t1)))


Code:
(defun silly-loop (n)
"Return the time, in seconds, to run N iterations of a loop."
(let ((t1 (get-universal-time)))
(loop while (> (setq n (1- n)) 0))
(- (get-universal-time) t1)))




For emacs, the result is 10 seconds if using interpreter, then 3 seconds if using byte-code.

But for CLISP interpreter, it’s a horrible 48 seconds, I was wondering what’s the difference? And why such a large gap? Maybe CLISP VM is stack-based while emacs is something maybe register-based?

Thanks in advance, ciao! :)

_________________
:Octane: (Sakura) :O2: (Sasuke) :1600SW: (Naruto) ... lil Jesse! (O2 laptop)
“Imagination is more important than knowledge.“ – A. Einstein
could you recommend a great book/pdf to learn emacs' implementation of lisp? Or maybe better, sbcl or any other "advanced" clisp?

_________________
:Onyx2:
What are you using for the argument? Too large a number won't be representable as a fixnum.

_________________
:PI: :O2: :Indigo2IMP: :Indigo2IMP:
mia wrote:
could you recommend a great book/pdf to learn emacs' implementation of lisp? Or maybe better, sbcl or any other "advanced" clisp?
hi mia, sorry but i usually use the net to search specific commands, also did use the emacs tutorial inside emacs too.. but for a Lisp pdf, now im reading Practical Lisp ;) also i mentioned that video from MIT but i just know it was Scheme that they taught hehe but still useful ;)

robespierre wrote:
What are you using for the argument? Too large a number won't be representable as a fixnum.
hi robes! geez silly me i forgot to put it here, thanks :) its:

Code:
(silly-loop 50000000)


today i will try compile it on CLISP byte-code to see the difference..

_________________
:Octane: (Sakura) :O2: (Sasuke) :1600SW: (Naruto) ... lil Jesse! (O2 laptop)
“Imagination is more important than knowledge.“ – A. Einstein
some update. i was able to compile it on CLISP and here is the result:

Code:
D:\>clisp -q -norc test.fas
7

D:\>clisp -q -norc test.lsp
47


compiler = 7 secs
interpreter = 47 secs

compared to emcas lisp:
compiler = 3 secs
interpreter = 10 secs

all on the same machine, does it mean the VM is the difference?

_________________
:Octane: (Sakura) :O2: (Sasuke) :1600SW: (Naruto) ... lil Jesse! (O2 laptop)
“Imagination is more important than knowledge.“ – A. Einstein
has anyone managed to compile sbcl on irix?

_________________
:Onyx2:
when the code is interpreted, there is no VM; the interpreter simulates the effect of running the code by means of its own data structures, called "environment objects". To reference a variable, it will make several function calls: to locate the symbol in the current environment, get its value cell, and access the value. In addition, the interpreter is self-recursive, and calls itself on every subform that it evaluates. So your function that loops 50 million times could (on one implementation here) result in calling the interpreter 350 million times.

A CL interpreter has more to do, since there can be symbol-macros and handlers and restarts and things that need to be managed. Those always need to be checked, even if the code doesn't use them. For these and other reasons, most developers always compile their code before running it. (Compiling also lets you see warnings about mistakes in your code!)

_________________
:PI: :O2: :Indigo2IMP: :Indigo2IMP:
robespierre wrote:
A CL interpreter has more to do, since there can be symbol-macros and handlers and restarts and things that need to be managed.
so does it mean emacs interpreter only manage a few things that's why it was faster?

but how about the compiled byte-code, byte-codes should run on VM's right? what i know is CLISP use a stack-based VM for their byte-code while im not sure for emacs. but comparing the compiled performance, emacs still has beaten CLISP many folds so i wonder how emacs lisp did this, is it the VM design they use? btw please correct me, all byte code generated by LISP compilers will be run by their own VM's right? not the interpreter?

mia wrote:
has anyone managed to compile sbcl on irix?
hmm maybe Oskar knows? or he also looking for this :)

_________________
:Octane: (Sakura) :O2: (Sasuke) :1600SW: (Naruto) ... lil Jesse! (O2 laptop)
“Imagination is more important than knowledge.“ – A. Einstein
mia wrote:
has anyone managed to compile sbcl on irix?

Never actually tried, because I found cmucl (today a.k.a. Clozure CL) quite OK.

http://www.pmsf.de/pub/cmucl/release/18e/

_________________
:Octane2: :O2: :Indy: :Indy:

Person A: "I'm going to hack the Internet."
Person B: "Which one?"
Person A: (dramatic pause) "ALL of them!"
18e is very old, and is unsupported by several common packages like ASDF.

_________________
:PI: :O2: :Indigo2IMP: :Indigo2IMP:
Indeed, it's very old. Perhaps we should look at making a nekoware tardist of a recent CCL or SBCL.

_________________
:Octane2: :O2: :Indy: :Indy:

Person A: "I'm going to hack the Internet."
Person B: "Which one?"
Person A: (dramatic pause) "ALL of them!"
I've never really understood Lisp, probably because I've been using RPL for 20+ years and the fact that operators are placed prior to the operands confuses me. I understand Haskell much better though, subsequently I ask. Is there anything Lisp has to offer over other *reputable* functional languages such as Haskell?

_________________
:Onyx2:
Funnily enough, John Carmack talked some about this at this year's superlong quakecon talk. Relevant video part: https://www.youtube.com/watch?v=1PhArSujR_A

Keep in mind that his point of view is 3d gaming.

_________________
:Octane: halo , oct ane
N.B.: I tend to talk out of my ass. Do not take it too seriously.
mia wrote:
I've never really understood Lisp, probably because I've been using RPL for 20+ years and the fact that operators are placed prior to the operands confuses me. I understand Haskell much better though, subsequently I ask. Is there anything Lisp has to offer over other *reputable* functional languages such as Haskell?


As somebody who doesn't use Lisp or know much about it I still see the value in it. The syntax is very straightforward. People know how to implement it and get good performance out of it since it's been around a long time. Other functional languages are too ugly and wierd and have problems with performance and garbage collection for edge-cases. Maybe in the future that will improve. Lisp is something old school that's proved itself. I tend to like old stuff.

_________________
Paint It Blue
SBCL on IRIX would require a port, since it has never run on that flavor of Unix. Maybe a month's work?
The MIPS compiler backend would also benefit from an update to 64-bit, which might be easier, and allow some version of CMUCL to link to modern N32 libraries.

_________________
:PI: :O2: :Indigo2IMP: :Indigo2IMP:
Nobody was asking for this, but since I have been playing around with it recently, I ran this benchmark (maybe we should call it the "dhumbstone"?) in a Lisp Listener on my TI microExplorer. It scored 37 seconds, for n=50000. I don't even want to think about how long I'd be waiting for n=50000000.

Well, probably something approaching 37000 seconds actually. So, around 10 hours. That doesn't sound like very much fun.

I'm just curious enough to compare it with the "compiled" option, where you can have an application run standalone in the Mac OS without the full Lisp system running (but using the microExplorer CPU). I should see if I can learn how to even do that.
:OnyxR: :IRIS3130: :IRIS2400: :Onyx: :ChallengeL: :4D220VGX: :Indigo: :Octane: :Cube: :Indigo2IMP: :Indigo2: :Indy:
OpenGenera on Linux is the same as Alpha, except with the VLM hacked to run on x86-64 linux instead of Alpha OSF. My smallest Alpha is a DS20e (that still weighs 100+ lbs.), half the PCI cards in it aren't supported in DU4, and I was never able to get OG2 to run on Tru64 v5. Frankly, OG2 in a Linux VM makes anything else really difficult to recommend.
:OnyxR: :IRIS3130: :IRIS2400: :Onyx: :ChallengeL: :4D220VGX: :Indigo: :Octane: :Cube: :Indigo2IMP: :Indigo2: :Indy:
I've read that ( in at least xemacs ), lisp code is compiled to byte-code, and because emacs-lisp is a smaller language than common lisp, they can get away with hacks such as getting rid of the first few ascii bits, and using smaller space per opcode. ( which the documentation claims makes this a much faster way to execute code ( according to jwz ).

It's kind-of how risc can be faster than intel opcodes because the archetecture is designed to do one thing quickly.
:Octane2: 400Mhz V8
geo wrote: mmm how about the Genera under Alpha? i think that was the latest setup from Symbolics right? do you have such setup? :)


n=50000000 with OpenGenera 2 on Alpha DS20e (2x EV67 667 MHz)

Interpreted = 3752
Compiled = 6
:OnyxR: :IRIS3130: :IRIS2400: :Onyx: :ChallengeL: :4D220VGX: :Indigo: :Octane: :Cube: :Indigo2IMP: :Indigo2: :Indy:
kjaer wrote: n=50000000 with OpenGenera 2 on Alpha DS20e (2x EV67 667 MHz)

Interpreted = 3752
Compiled = 6


thanks kjaer!! this will be added to my little notebook :)

wow! you waited an hour for the interpreter :shock: :shock:

ok will find some time to put my result here soon ;)

hmm was wondering how a standalone Lisp machine would perform this..
:Octane: (Sakura) :O2: (Sasuke) :1600SW: (Naruto) ... lil Jesse! (O2 laptop)
“Imagination is more important than knowledge.“ – A. Einstein