From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Damien Mattei Newsgroups: gmane.lisp.guile.user Subject: Re: speed difference between Guile and Racket (and Python) Date: Wed, 9 Nov 2022 15:24:24 +0100 Message-ID: References: <871qqfqfjn.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25342"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user@gnu.org To: "Dr. Arne Babenhauserheide" Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Nov 09 15:26:42 2022 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1osm2L-0006M3-Dq for guile-user@m.gmane-mx.org; Wed, 09 Nov 2022 15:26:41 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osm1I-0002P6-Kk; Wed, 09 Nov 2022 09:25:36 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osm10-0002NO-HE for guile-user@gnu.org; Wed, 09 Nov 2022 09:25:25 -0500 Original-Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1osm0V-0002Y2-5N for guile-user@gnu.org; Wed, 09 Nov 2022 09:25:02 -0500 Original-Received: by mail-ed1-x530.google.com with SMTP id s12so17877719edd.5 for ; Wed, 09 Nov 2022 06:24:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Tv6p42ai6ElHlru8q66ml8TBjAnTNdJC2qs6Z/xhQ90=; b=P+QitBgpR3uQKoYR3sAbK0gbpNpJovJ+K1X+hdU2LmLQB0BfxO9Qf1UOOcviv8yQQ+ ACV7Ao6sqmyaL+NLGKESrOKcO2mWV+XOanFN/B+/zmqUnDFbAEdgqbF7LKcxIbvmEmoy SiBAPg7Ew0nxvLSMnjmf/hSagQZ2v2qCzl9u4K4EpH4f8oGklIyrI0DTf1p55B8UA+kI DucaVnfWL3P47mcR/yLeoGR0is6BV4iFSe9D1gw7Dw2lDeR2Jt53VLEjvIRyXH32n4hF w+FNt5U991QxJ3B2kTPxLTDDrqhDyKQ0uDN9rvsiwunIlNWQ/D2l6Kp4OyymhRFukK66 U2uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Tv6p42ai6ElHlru8q66ml8TBjAnTNdJC2qs6Z/xhQ90=; b=DKHyqJK/VgUn0ifOg+FhUa9ueHmQReWixkRlbkdrONTekcm2t22i0iTxgLESBOQbz1 n0iIdJJeKz79fBU35Z1wGIX31NVhaSL2D4bM4VngsNJQLnux2mvMqvvOCdZIiRr3UEPZ 1WbQH7Kd9cAdeIqzsvEd2F6/RYOTL2DTLk21n5dfHV/NkL/TR1C8bLZflxvqAwY4epD6 XC6JD5mWaP6kCfWKU49Amd8sKghejrhRXxIo49fny5yO8Bh7RnYKbvvLgBvcKUMe5gfx paPw5cm0yH2awLyRomW+DT+6ehnf9tCKy1fCYNTmuGpjjFnY2oEbnuUDUvqpnDvKvbsZ qEgA== X-Gm-Message-State: ACrzQf2nWeUv+BJwUesWIQllx8SMhaH6zMYqFLbJ6r2fNQp2nEEhqU9P DOGes7WgMz1rmI6se6Va81Bc/OOKLV8hAkc9uIkFTQYY X-Google-Smtp-Source: AMsMyM7vC2z+S+FljnBqitAGsB7kjN3t9lFZguwSF6F9Ni0xMPWDs3rg491B+C1C0Pbg+XxSxucx64jsR1M2U5Q3Dyg= X-Received: by 2002:a05:6402:1497:b0:462:c929:7e89 with SMTP id e23-20020a056402149700b00462c9297e89mr61179990edv.149.1668003875508; Wed, 09 Nov 2022 06:24:35 -0800 (PST) In-Reply-To: <871qqfqfjn.fsf@web.de> Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=damien.mattei@gmail.com; helo=mail-ed1-x530.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:18699 Archived-At: 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 =3D 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 wrote: > > Damien Mattei writes: > > > when comparing the (almost) same code running on Guile and Racket i fin= d > > 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/logi= ki%2B.scm#L3092 > > Could you give the shell commands to setup and run your speed-test? > > Best wishes, > Arne > -- > Unpolitisch sein > hei=C3=9Ft politisch sein, > ohne es zu merken. > draketo.de >