unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: "Linus Björnstam" <linus.internet@fastmail.se>
To: "Damien Mattei" <damien.mattei@gmail.com>,
	guile-user <guile-user@gnu.org>
Subject: Re: speed difference between Guile and Racket (and Python)
Date: Tue, 08 Nov 2022 09:03:52 +0100	[thread overview]
Message-ID: <63343719-ae70-408a-8dde-9b1ad41bcdcd@app.fastmail.com> (raw)
In-Reply-To: <CADEOadc3eEpMhS3TyzPni=rE0GoAzaZtPWxPkJD95Sa2J1J39A@mail.gmail.com>

Hi!

First of all, Guile is (currently) slower than racket or many things. The interpreter should not be slower than running from the command line. 

One thing you could do is modularize the code. Currently there will be a function call overhead, since guile cannot know if a function has been replaced via set!. Andy wrote about it here: http://wingolog.org/archives/2019/06/26/fibs-lies-and-benchmarks

Secondly, your code uses quite a lot of mutation. I got scheme+ and macroexpanded it. I didn't look for hot code, but there was a liberal use of set!. That means you will get a boxing overhead (which should be true for both racket and guile), but since I believe I read somewhere that racket is better at type-inference than mainline chez I think it is safe to say it probably does better than guile with mutation, at least locally. Most notably, the for loops are definitely slower than the same tail-recursive let loop.

Also, for seems to expand to use call/cc instead of delimited continuations (which are supported in both guile and racket). The punishment in racket for call/cc is low, whereas it is high in guile. 


Best regards
  Linus Björnstam

On Sun, 6 Nov 2022, at 17:01, Damien Mattei wrote:
> hello,
>
> when comparing the (almost) same code running on Guile and Racket i find
> big speed difference:
> still computing some logic expression Cn minimalized in disjunctive normal
> form:
>
> C9: 35" Guile MacOS Apple silicon
>
> C10: 37' Guile MacOS Apple silicon
>              10" Guile // MacOS (8cores) Apple silicon
>                 4" Racket // MacOS Apple silicon
>
> C11 : 1'17 Guile // MacOS Apple silicon
> C11: 56" Guile // (6cores) Intel, Linux
> 11" Racket // MacOS Apple silicon
> 22" Python sympy no // MacOS Apple silicon
>
> C12: 1'24" Racket // MacOS Apple silicon
> 1'34 Racket MacOS Apple silicon
> 1'10" Python sympy no // MacOS Apple silicon
> 9' 25" Guile // MacOS Apple silicon
>
> C13: 17' ,20', 24'(use <8Gb of memory) Racket MacOS Apple silicon
> 15' 37",16' 10" Racket // MacOS Apple silicon
> 7'50" Python sympy no // MacOS Apple silicon
>
> par-map:
> test : succeed
> computation: very slow
>
> threads:
> test: blocked
> computation:partial and crash
>
> my conclusion about // is that in Guile and Racket my // schema is not
> good, i have poor gain.
>
> The strange thing was why in Guile i had :
> C10: 37' Guile MacOS Apple silicon
>              10" Guile // MacOS (8cores) Apple silicon
> 37' in sequential code and 10" in // with only 8 core speed up: because in
> // code i use vectors and in sequential code list i think.
>
> So now the question is why is Guile slow compared to Racket? is it again
> about the lists like versus vectors? or not?
>
> compared with Python sympy (no // support) it has the same magnitude order
> than Racket (// almost change nothing:16' versus 17' for C13) but twice
> more speed... but Python is known to be slow ( not compiled code)...
>
> i'm running Guile in the interpreter (same for Racket), would it be more
> fast in command line execution? sorry if my question is stupid, i know
> Bigloo can compile rather being in interpreter,but do not know about guile
> , each time i modify my code it seems to be compiled... (message: ;;;
> compiling......)
>
> last version of code is here:
> https://github.com/damien-mattei/library-FunctProg/blob/master/guile/logiki%2B.scm#L3092
>
> Best regards,
> Damien



      parent reply	other threads:[~2022-11-08  8:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-06 16:01 speed difference between Guile and Racket (and Python) Damien Mattei
2022-11-06 22:23 ` Speed " Hans Åberg
2022-11-06 22:35   ` Damien Mattei
2022-11-07  9:21 ` speed " Dr. Arne Babenhauserheide
2022-11-07 13:23   ` Zelphir Kaltstahl
2022-11-09 14:24   ` Damien Mattei
2022-11-08  8:03 ` Linus Björnstam [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=63343719-ae70-408a-8dde-9b1ad41bcdcd@app.fastmail.com \
    --to=linus.internet@fastmail.se \
    --cc=damien.mattei@gmail.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).