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