about LISP performance

For friendly off topic discussion not covered in a forum above.
Forum rules
No politics, please.
User avatar
geo
Posts: 527
Joined: Tue Jul 21, 2009 5:07 am
Location: Nagano-ken, Shiojiri-shi, Japan

about LISP performance

Unread postby geo » Fri Aug 02, 2013 3:27 am

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: Select all

(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: Select all

(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

User avatar
mia
Posts: 1055
Joined: Wed Feb 19, 2003 1:54 pm

Re: about LISP performance

Unread postby mia » Fri Aug 02, 2013 5:30 am

could you recommend a great book/pdf to learn emacs' implementation of lisp? Or maybe better, sbcl or any other "advanced" clisp?
:Onyx2:

robespierre
Posts: 1554
Joined: Mon Sep 12, 2011 2:28 pm
Location: Boston

Re: about LISP performance

Unread postby robespierre » Fri Aug 02, 2013 9:35 am

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

User avatar
geo
Posts: 527
Joined: Tue Jul 21, 2009 5:07 am
Location: Nagano-ken, Shiojiri-shi, Japan

Re: about LISP performance

Unread postby geo » Fri Aug 02, 2013 6:47 pm

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: Select all

(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

User avatar
geo
Posts: 527
Joined: Tue Jul 21, 2009 5:07 am
Location: Nagano-ken, Shiojiri-shi, Japan

Re: about LISP performance

Unread postby geo » Fri Aug 02, 2013 8:28 pm

some update. i was able to compile it on CLISP and here is the result:

Code: Select all

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

User avatar
mia
Posts: 1055
Joined: Wed Feb 19, 2003 1:54 pm

Re: about LISP performance

Unread postby mia » Fri Aug 02, 2013 9:10 pm

has anyone managed to compile sbcl on irix?
:Onyx2:

robespierre
Posts: 1554
Joined: Mon Sep 12, 2011 2:28 pm
Location: Boston

Re: about LISP performance

Unread postby robespierre » Fri Aug 02, 2013 10:39 pm

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:

User avatar
geo
Posts: 527
Joined: Tue Jul 21, 2009 5:07 am
Location: Nagano-ken, Shiojiri-shi, Japan

Re: about LISP performance

Unread postby geo » Fri Aug 02, 2013 11:16 pm

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

User avatar
tomvos
Donor
Donor
Posts: 134
Joined: Fri Jul 04, 2008 1:08 pm
Location: Aachen, Germany, Europe
Contact:

Re: about LISP performance

Unread postby tomvos » Sat Aug 03, 2013 1:41 pm

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/
:Fuel: :Octane2: :O2: :O2: :1600SW: :Indy: :Indy:
Where subtlety fails us we must simply make do with cream pies.

robespierre
Posts: 1554
Joined: Mon Sep 12, 2011 2:28 pm
Location: Boston

Re: about LISP performance

Unread postby robespierre » Sun Aug 04, 2013 3:14 pm

18e is very old, and is unsupported by several common packages like ASDF.
:PI: :O2: :Indigo2IMP: :Indigo2IMP:

User avatar
tomvos
Donor
Donor
Posts: 134
Joined: Fri Jul 04, 2008 1:08 pm
Location: Aachen, Germany, Europe
Contact:

Re: about LISP performance

Unread postby tomvos » Mon Aug 05, 2013 4:45 am

Indeed, it's very old. Perhaps we should look at making a nekoware tardist of a recent CCL or SBCL.
:Fuel: :Octane2: :O2: :O2: :1600SW: :Indy: :Indy:
Where subtlety fails us we must simply make do with cream pies.

User avatar
mia
Posts: 1055
Joined: Wed Feb 19, 2003 1:54 pm

Re: about LISP performance

Unread postby mia » Mon Aug 05, 2013 7:32 am

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:

User avatar
duck
Donor
Donor
Posts: 737
Joined: Mon Oct 27, 2003 5:22 pm
Location: Jakobstad, Finland
Contact:

Re: about LISP performance

Unread postby duck » Mon Aug 05, 2013 7:45 am

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, octane Image knightrider, d i g i t a l AlphaPC164, pond, soekris net6501, misc cool stuff in a rack
N.B.: I tend to talk out of my ass. Do not take it too seriously.

robespierre
Posts: 1554
Joined: Mon Sep 12, 2011 2:28 pm
Location: Boston

Re: about LISP performance

Unread postby robespierre » Mon Aug 05, 2013 11:20 am

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:

User avatar
kjaer
Posts: 424
Joined: Wed May 07, 2008 7:47 pm
Location: Seattle, WA
Contact:

Re: about LISP performance

Unread postby kjaer » Mon Oct 28, 2013 7:47 pm

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:


Return to “Everything Else”

Who is online

Users browsing this forum: Ahrefs [Bot] and 0 guests