From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Linus_Bj=C3=B6rnstam?= Newsgroups: gmane.lisp.guile.user Subject: Re: speed difference between Guile and Racket (and Python) Date: Tue, 08 Nov 2022 09:03:52 +0100 Message-ID: <63343719-ae70-408a-8dde-9b1ad41bcdcd@app.fastmail.com> References: 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="38503"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.7.0-alpha0-1115-g8b801eadce-fm-20221102.001-g8b801ead To: "Damien Mattei" , guile-user Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Tue Nov 08 09:05:08 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 1osJbV-0009i9-2n for guile-user@m.gmane-mx.org; Tue, 08 Nov 2022 09:05:07 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osJaz-0005je-7R; Tue, 08 Nov 2022 03:04:33 -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 1osJam-0005br-Mx for guile-user@gnu.org; Tue, 08 Nov 2022 03:04:27 -0500 Original-Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osJak-0002r8-6Z for guile-user@gnu.org; Tue, 08 Nov 2022 03:04:20 -0500 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 532183200955; Tue, 8 Nov 2022 03:04:14 -0500 (EST) Original-Received: from imap51 ([10.202.2.101]) by compute4.internal (MEProxy); Tue, 08 Nov 2022 03:04:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.se; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1667894653; x= 1667981053; bh=TX1jKr21oCibH1TmS3isgBsjkczWVJid0K2c9ybmYE4=; b=R N/5vU6agjnqderMizy5A9O2lo7z8DbRKDWpifP1uIw8nj8HJ4QMU9az6Ss3WzN3Y HLGfjRSqpAXWZ2iokocE3EZlzgk1PcVG03nwJdLzCJqlqEEdBp8AYapuDD4PXd8t ufvwY0rjQTuTdAnxDDZhDw160yCY/uQgTQiFP0xnRyCfF8ZsiQeyPzq7l8kLw2bX ll7btmjA4XVKk5dJExwWGlZcvJlXQ/396g1T/XVEr/z6VWA9xPIzq1EP6RCZLLxW asJcGjtXe435yc7Q2/sGONbnEEFN8Nfhsy3fvV2RFVR+7Q36bfJGd5RSrV8ly81X O20JiDijQv4h35vow7teg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1667894653; x=1667981053; bh=T X1jKr21oCibH1TmS3isgBsjkczWVJid0K2c9ybmYE4=; b=ijWqY+XJx6DYLg7yi JKF5GxyQ4pK0IJ0VKrtdtf0AFqfhELqKwuvKjEmhEDzfGe0Rq0wqGVPmOG60YXnu rWErg1rzKjKH3mKc1j/a4vGDf40QPBEDOQXvVo81EGj4RIJHVImCyAE4VLznzpNn 8opLwqmg/DTUk8Mxgd4tN5MH0OObTzMt2bAVrYlVvb3Q4rfEaQtFEDhpHiEOkZcN GSE8CzimlwJ4SJS31crqMH4MZxmO+sdNjJCC+z/T+6O1mUipG7eiH/DDv/Mg/jZc OWts+zJmip7ZvoLR21YvRbMLoCLkN8bCXz0juma3fJ6XQj8jZNZcrRiEpR9Mwu3f E4fsg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrvdelgdduudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpefnihhn uhhsuceujhpnrhhnshhtrghmuceolhhinhhushdrihhnthgvrhhnvghtsehfrghsthhmrg hilhdrshgvqeenucggtffrrghtthgvrhhnpeduffduheekheeileegheeliefhkefgteff veevgfelteffgfdvueekgfeiieelgfenucffohhmrghinhepfihinhhgohhlohhgrdhorh hgpdhgihhthhhusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhep mhgrihhlfhhrohhmpehlihhnuhhsrdhinhhtvghrnhgvthesfhgrshhtmhgrihhlrdhsvg X-ME-Proxy: Feedback-ID: i57f3436d:Fastmail Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id C5B5BB60086; Tue, 8 Nov 2022 03:04:13 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: Received-SPF: pass client-ip=64.147.123.21; envelope-from=linus.internet@fastmail.se; helo=wout5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:18698 Archived-At: Hi! First of all, Guile is (currently) slower than racket or many things. Th= e interpreter should not be slower than running from the command line.=20 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/archive= s/2019/06/26/fibs-lies-and-benchmarks Secondly, your code uses quite a lot of mutation. I got scheme+ and macr= oexpanded 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 f= or both racket and guile), but since I believe I read somewhere that rac= ket 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-re= cursive let loop. Also, for seems to expand to use call/cc instead of delimited continuati= ons (which are supported in both guile and racket). The punishment in ra= cket for call/cc is low, whereas it is high in guile.=20 Best regards Linus Bj=C3=B6rnstam On Sun, 6 Nov 2022, at 17:01, Damien Mattei wrote: > hello, > > when comparing the (almost) same code running on Guile and Racket i fi= nd > big speed difference: > still computing some logic expression Cn minimalized in disjunctive no= rmal > 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: becaus= e 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 aga= in > about the lists like versus vectors? or not? > > compared with Python sympy (no // support) it has the same magnitude o= rder > 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 mo= re > 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 g= uile > , 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/l= ogiki%2B.scm#L3092 > > Best regards, > Damien