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?Linus_Bj=C3=B6rnstam?= Newsgroups: gmane.lisp.guile.devel,gmane.lisp.guile.user Subject: Re: Guile's time execution issues Date: Mon, 04 May 2020 22:50:25 +0200 Message-ID: References: <87d07u182a.fsf@gnu.org> <87a72q77gr.fsf@gnu.org> <87r1w0rqhc.fsf@gnu.org> <874ksvqx7k.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="70593"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.3.0-dev0-351-g9981f4f-fmstable-20200421v1 Cc: =?UTF-8?Q?Aleix_Conchillo_Flaqu=C3=A9?= , guile-user , guile-devel To: =?UTF-8?Q?Ludovic_Court=C3=A8s?= Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Mon May 04 22:51:14 2020 Return-path: Envelope-to: guile-devel@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 1jVi3W-000IEv-2w for guile-devel@m.gmane-mx.org; Mon, 04 May 2020 22:51:14 +0200 Original-Received: from localhost ([::1]:46460 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVi3U-0006FH-MJ for guile-devel@m.gmane-mx.org; Mon, 04 May 2020 16:51:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34738) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVi3A-0006E4-JK; Mon, 04 May 2020 16:50:53 -0400 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:43511) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVi37-0000jU-7l; Mon, 04 May 2020 16:50:51 -0400 Original-Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 062225C00BF; Mon, 4 May 2020 16:50:48 -0400 (EDT) Original-Received: from imap1 ([10.202.2.51]) by compute7.internal (MEProxy); Mon, 04 May 2020 16:50:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=veryfast.biz; h= mime-version:message-id:in-reply-to:references:date:from:to:cc :subject:content-type:content-transfer-encoding; s=fm2; bh=nJS0b vB0aNCBd2N4nyUd4mqQu8ANsVAXQ2ko4Sm6rnQ=; b=bD0Qh+w5Fjvsu08q/VpOx jeHASrDk7C4p8Y2gj2E8jlrC5Lo+JpI/3xxcxTfIVTv+DwLcZpEbUSPA6Rhy41TA GAPctpAOUFEEqextI5UWbomJWY7ckm2lHwJINsU763ZeMz6UCYZsLjtiW9gNXLy5 QXGTaRKd+IaeuxoqqGHvry2RH0ugl4XYZyOfjs/2BYkwHiFoCXeTsk1+4VIgDNKs Nh0f7fsXVINtrkhTGhOXCVo7Rp2O2f5WQflD6I/yv6ZF1MUtj/9aK5ZUREOhiGEb QGc1D98+mQVHL+MIN1Xl+TmeLbCe66krP0n9WgRqQmOtde07UsPx3y22JXZTbSr5 Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=nJS0bvB0aNCBd2N4nyUd4mqQu8ANsVAXQ2ko4Sm6r nQ=; b=DrRjE8Fp6ymNrv9pM4GjPXfsjJF2rwkU00Xin4UoCjy+1su3188tx4dWi rhTYA9JhrVIAmffbdjbKg6U32L8O0q9n2LGDN+rgJD6yVMMmDqciJ+Jf++uVf5Gd /EdLqtW6ctII5LmIbckhXrs9CCP/K/HcHX6IPDcPyGAIHXXZIyL/hDU0DzMxNRBH 02ZJaZyA8aAXq2OjTWSxl31xISWjHx3SjvD1lKLLWffbS1f6VIHuzNVYcVBNjsTv bOnW7LzodzXQWh7D0u21+eMHEp1G65yMFYD6B7eKc9B8wlZ6mpn/hfvVAwQELp1r 2JtH/n23wAuv66rgREn2qn5KecUYw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrjeeggddugeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpefnihhn uhhspgeujhpnrhhnshhtrghmuceolhhinhhushdrsghjohhrnhhsthgrmhesvhgvrhihfh grshhtrdgsihiiqeenucggtffrrghtthgvrhhnpeefvdeuhfejtdefffekuedutdejheeh gffhffdvjeelieekleffjedugfdvvdffvdenucffohhmrghinhepghhithhhuhgsrdgtoh hmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhhi nhhushdrsghjohhrnhhsthgrmhesvhgvrhihfhgrshhtrdgsihii X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id AB190C200A4; Mon, 4 May 2020 16:50:47 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: <874ksvqx7k.fsf@gnu.org> Received-SPF: pass client-ip=66.111.4.28; envelope-from=linus.bjornstam@veryfast.biz; helo=out4-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/04 16:10:21 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:20511 gmane.lisp.guile.user:16427 Archived-At: You didn't see my other reply. The matching code isn't suboptimal. The e= quality predicate is The problem is that match compares using equal? ev= en for literal chars (where eqv? is a lot faster). It would be a rather = trivial optimization to do, either to match.scm (meaning: breaking with = upstream and use syntax-case) or to the guile compiler in general (chang= ing equal? to eqv, when there are character literals), which seems ok-is= h for this use-case but at very little benefit in general. A long-term goal of mine is to write a pattern matcher with the optimisa= tions that the racket matcher does (among other things: some serious lis= t matching reordering!). That is a daunting task though. --=20 Linus Bj=C3=B6rnstam On Mon, 4 May 2020, at 22:09, Ludovic Court=C3=A8s wrote: > Hi, >=20 > Linus Bj=C3=B6rnstam skribis: >=20 > > On Mon, 4 May 2020, at 11:36, Ludovic Court=C3=A8s wrote: > > =20 > >> > One thing I found is that `match` is slow. The code looked nicer = but had 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= , which 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)= instead of (a b ...). > >> It doesn=E2=80=99t have the same meaning, but often the end result = is the same, > >> for instance because you=E2=80=99ll later match on =E2=80=98b=E2=80= =99 anyway. > >>=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= : https://github.com/aconchillo/guile-json/commit/ad4b06d86e4822466983d0= 0f55474c8f664b538d >=20 > It would be nice if you could pinpoint which one of these changes caus= es > a difference, because: >=20 > --8<---------------cut here---------------start------------->8--- > scheme@(guile-user)> ,optimize (match (peek-char port) ((? eof-object?= )=20 > 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--- >=20 > What might make a difference is the code bloat when using =E2=80=98or=E2= =80=99: >=20 > --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--- >=20 > but even that sounds unlikely. >=20 > You=E2=80=99re compiling with -O2, right? >=20 > Thanks, > Ludo=E2=80=99. >