From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Newsgroups: gmane.lisp.guile.user,gmane.lisp.guile.devel Subject: Re: Guile's time execution issues Date: Mon, 04 May 2020 22:09:03 +0200 Message-ID: <874ksvqx7k.fsf@gnu.org> References: <87d07u182a.fsf@gnu.org> <87a72q77gr.fsf@gnu.org> <87r1w0rqhc.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="16487"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cc: guile-user , guile-devel To: Linus =?utf-8?Q?Bj=C3=B6rnstam?= Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Mon May 04 22:09:21 2020 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 1jVhOz-0004Bm-Pk for guile-user@m.gmane-mx.org; Mon, 04 May 2020 22:09:21 +0200 Original-Received: from localhost ([::1]:55464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVhOy-00015O-R9 for guile-user@m.gmane-mx.org; Mon, 04 May 2020 16:09:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVhOm-00014f-Ss; Mon, 04 May 2020 16:09:08 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:39640) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVhOm-0002f1-FF; Mon, 04 May 2020 16:09:08 -0400 Original-Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=54780 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jVhOj-0000LI-OA; Mon, 04 May 2020 16:09:07 -0400 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 16 =?utf-8?Q?Flor=C3=A9al?= an 228 de la =?utf-8?Q?R?= =?utf-8?Q?=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu In-Reply-To: ("Linus \=\?utf-8\?Q\?Bj\=C3\=B6rnstam\=22's\?\= message of "Mon, 04 May 2020 13:19:34 +0200") X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 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" Xref: news.gmane.io gmane.lisp.guile.user:16426 gmane.lisp.guile.devel:20510 Archived-At: Hi, Linus Bj=C3=B6rnstam skribis: > On Mon, 4 May 2020, at 11:36, Ludovic Court=C3=A8s wrote: >=20=20 >> > One thing I found is that `match` is slow. The code looked nicer but h= ad to change it back to lets and conds as the performance >> > increase was ~2 seconds. >>=20 >> Oh, in which case exactly? And are you sure your hand-written code is >> equivalent to the =E2=80=98match=E2=80=99 code (it=E2=80=99s common for = hand-written code to be >> more lax than =E2=80=98match=E2=80=99)? >>=20 >> One thing to pay attention to is the use of =E2=80=98list?=E2=80=99, whi= ch is O(N), and >> is implied by ellipses in =E2=80=98match=E2=80=99. If you want to use = =E2=80=98match=E2=80=99 in a way >> that avoids =E2=80=98list?=E2=80=99, write patterns such as (a . b) inst= ead of (a b ...). >> It doesn=E2=80=99t have the same meaning, but often the end result is th= e same, >> for instance because you=E2=80=99ll later match on =E2=80=98b=E2=80=99 a= nyway. >>=20 >> (I wish we can one day have a proper list type disjoint from pairs=E2=80= =A6) > > The change is here: he is only matching against chars and predicates: htt= ps://github.com/aconchillo/guile-json/commit/ad4b06d86e4822466983d00f55474c= 8f664b538d It would be nice if you could pinpoint which one of these changes causes a difference, because: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,optimize (match (peek-char port) ((? eof-object?) x) = ((? whitespace?) w) (_ e)) $84 =3D (let ((v (peek-char port))) (cond ((eof-object? v) x) ((whitespace? v) w) (else e))) --8<---------------cut here---------------end--------------->8--- What might make a difference is the code bloat when using =E2=80=98or=E2=80= =99: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,optimize (match (peek-char port) ((or #\a #\b #\c #\d= ) x)) $86 =3D (let ((v (peek-char port))) (cond ((equal? v #\a) x) ((equal? v #\b) x) ((equal? v #\c) x) ((equal? v #\d) x) (else ((@@ (ice-9 match) error) 'match "no matching pattern" v) #f))) --8<---------------cut here---------------end--------------->8--- but even that sounds unlikely. You=E2=80=99re compiling with -O2, right? Thanks, Ludo=E2=80=99.