guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: speed difference between Guile and Racket (and Python)


From: Damien Mattei
Subject: Re: speed difference between Guile and Racket (and Python)
Date: Wed, 9 Nov 2022 15:24:24 +0100

sorry for my late answer but i needed to test again (and modify code a bit)
a few precision:
-the code is perheaps hard to // : recursive algo versus imperative one
-only a portion of code is //( i // the unification of minterms because it
was really long to compute,but perheaps there are other bottlenecks,
perhaps some cartesian product of set need too // but i did not do it,all
algo are not easily parallelizable)
-i no more use thread or par-map but future with vectors
-the sequential code remains with lists

As it seems that // only speed up code because i use Vectors in the portion
of // code instead of list, i decided to compare Vectors and List, for this
i use the // code with options of a number of CPUs equal to 1, so it is
like the sequential code but still use Vectors and i can compare with the
sequential code of Lists

-Guile is 6x slower than Racket on this algo
-Racket is 2x slower than Python sympy but i do not know if the algo of
symPy is the same as mine, but it is written in Python (not C) witch has a
reputation of slowness and symPy has no support for //.
-I discover one thing about Racket because i benchmarks using version 7.7
and 8.6 but the last version is based on Chez Scheme which is more than 5x
faster,i upgrade my Linux system to this version today ,so i can no longer
test Racket 7.7 speed but it still appear on the bechmarks below.
-i did minor modif of code (remove useless sorting of variable and
expressions) this week improving speed by 10-20% on all system so some
older benchmarks can behavior incoherent with new ones.
-strange thing, Python use almost no memory and my algo gigas... but i use
Quine - Mc Cluskey and Petrick algorithms which are conventional algo for
this problem.
- @Linus:about Scheme+, mutability, i use it also with Racket and it  is
fast, 'for loops are various ,some old: for/basic for/break some recent but
all use (let () loop inside sometimes with call/cc i admit,but only when
usefull for 'breaking from loop.Indeed i read the link you provided and it
was very interesting.

here is the benchmarks, i used 2 systems:
Guile 3.0.7 ,Racket 8.6 , Python 3.9.6 SymPy 1.1 ,MacOS Apple silicon M1
(8cores), RAM: 16Gb, HD:SSD
Guile 3.0.1 ,Racket 7.7 ,Racket 8.6 (based on Chez Scheme !) , Python 3.7.4
, SymPyLinux Intel (6cores), RAM: 16Gb, HD:SSD

C9: 35" Guile MacOS Apple silicon M1
       50",40" (without useless sorting of sets) Guile Linux intel
       26" Racket 7.7 Linux  Intel

C10: 37' Guile MacOS Apple silicon M1
         47' Guile Linux intel
             10" Guile // MacOS (8cores) Apple silicon M1
               9" Guile // (1 core ! vector) Linux intel
                4" Racket 8.6 // MacOS Apple silicon M1
               7" Guile // (3 core  vector) MacOS Apple silicon M1
              43' Racket 7.7 Linux  Intel



C11 : 1'17 Guile // MacOS Apple silicon M1
          56" Guile // (1 core ! vector) Linux intel
1' Guile // (1 core ! vector) MacOS Apple silicon
           1' 04"Guile // (3 core  vector) MacOS Apple silicon
C11: 56" Guile // (6cores) Intel, Linux
1'08" (1 core ! vector) Linux intel
9 " Racket 8.6 MacOS Apple silicon
11" Racket 8.6 // MacOS Apple silicon
22" Python 3.9.6 sympy 1.1 no // MacOS Apple silicon
17" Python Linux intel
15" Racket 8.6 Linux  Intel

C12: 1'24" ,1' 20" Racket 8.6 // MacOS Apple silicon
1'34 ,1' 27" Racket 8.6 MacOS Apple silicon
1' 23" Racket 8.6 // (1 core !) MacOS Apple silicon
1'10" Python sympy no // MacOS Apple silicon
9' 25" Guile // MacOS Apple silicon
9',9'45" Guile (1 core ! vector) Linux intel
8' 37" Guile // (3 core  vector) MacOS Apple silicon
10' 10" Guile // (7 core  vector) MacOS Apple silicon
8'33" Guile // (1 core ! vector) MacOS Apple silicon
2'10" Python sympy no // Linux intel
2' 05" Racket 8.6 Linux  Intel

C13: 17' ,20', 24'(use <8Gb of memory) Racket MacOS Apple silicon
15' 37",16' 10" ,14' (last version of code) Racket // MacOS Apple silicon
14' Racket 8.6 // (1 core !) MacOS Apple silicon
7'50" Python 3.9.6 sympy 1.1 no // MacOS Apple silicon
1h37' Guile (1 core ! vector) Linux intel
17'20" Python sympy no // Linux Intel
16'35" Racket 8.6 (1 core !) Linux  Intel

but this not really important, i have enough data and computation result
,after for k > 13 computation of Ck would take many days even in Python as
it is an NP hard problem.

But i will check if other region of my code are better candidate to //
,because for now // brings almost nothing (except that with Guile the //
region is more fast because Vectors are more fast than List with Guile)

My conclusion for now that Racket 8.6 (confirm to be based on Chez Scheme
?) is a bit faster than Python :-)
 and they are 6x time faster than Guile 3 on this algo . Note that my algo
use more than 8Gb  of data for C13 when python use almost no memory (i
suppose symPy use only binary datas computed the dumb way when my algo
manipulate expressions symbolically....i suppose too that my unified
minterms made of 0 ,1 and 'x in list can be representated with base 3
numbers on 2bits but with a limitation of 64 /2 = 32 bits of variables
which is anyway never computable...NP-hard),i suppose changing my algo to
deal like symPy one would kick the ass of Python definitively both with
Racket and Guile by removing a lot of memory allocation and garbage
collector use.

i will check again the data structure of my code, i also will try to to
publish the full code i use for benchmarks.

Damien

post-note: i'm checking again because the code i wrote use call/cc generate
by macro in 'future and i'm not sure it is compatible with  ,when i test it
i find no speed up and i can not find what is wrong, i''m almost back to
the beginning of problem...

On Mon, Nov 7, 2022 at 10:28 AM Dr. Arne Babenhauserheide <arne_bab@web.de>
wrote:

>
> Damien Mattei <damien.mattei@gmail.com> writes:
>
> > when comparing the (almost) same code running on Guile and Racket i find
> > big speed difference:
>
> Schemes differ a lot in speed of different tasks, but Racket is one of
> the fastest ones. Factor 2 difference sounds plausible. For a
> comparison, see the r7rs benchmarks:
> https://ecraven.github.io/r7rs-benchmarks/
>
> That said, I have seen 10x speedups in Guile code when people went for
> optimizing it.
>
> > last version of code is here:
> >
> https://github.com/damien-mattei/library-FunctProg/blob/master/guile/logiki%2B.scm#L3092
>
> Could you give the shell commands to setup and run your speed-test?
>
> Best wishes,
> Arne
> --
> Unpolitisch sein
> heißt politisch sein,
> ohne es zu merken.
> draketo.de
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]