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.user Subject: Re: string-for-each vs. for-each+string->list performance Date: Sun, 07 Jun 2020 13:20:33 +0200 Message-ID: <5f405299-9249-4357-b6b1-0a81a7e3a033@www.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="ciao.gmane.io:159.69.161.202"; logging-data="642"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.3.0-dev0-519-g0f677ba-fm-20200601.001-g0f677ba6 To: =?UTF-8?Q?Aleix_Conchillo_Flaqu=C3=A9?= , guile-user Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sun Jun 07 13:21:26 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 1jhtMi-000Y3L-HT for guile-user@m.gmane-mx.org; Sun, 07 Jun 2020 13:21:25 +0200 Original-Received: from localhost ([::1]:36992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhtMh-0005zC-7R for guile-user@m.gmane-mx.org; Sun, 07 Jun 2020 07:21:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhtMW-0005xA-4c for guile-user@gnu.org; Sun, 07 Jun 2020 07:21:12 -0400 Original-Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:47019) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhtMS-0005lU-VJ for guile-user@gnu.org; Sun, 07 Jun 2020 07:21:11 -0400 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 9622753F; Sun, 7 Jun 2020 07:21:05 -0400 (EDT) Original-Received: from imap1 ([10.202.2.51]) by compute4.internal (MEProxy); Sun, 07 Jun 2020 07:21:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.se; h= mime-version:message-id:in-reply-to:references:date:from:to :subject:content-type:content-transfer-encoding; s=fm3; bh=Ssurb Ytu33OKtu+7SUo3w59RA1bHXwj50BS2Kok1MN0=; b=cG+zWkPXBnWab/0KrSN8A Am+O5/XWXKh5JgdHXbcEuovQZsBWKw2pG+a2iTXix0KfQSJ8ugGqPJVLlw8X/KzD 8Ros9Ye9mxvZtiaBngesucHYh0FcwAd9ajwFnuP7HS/SeRPn42hpLCK9ELP+U2pv n/0/OM4us+a9D83FtGns1ZbpLbveHZA91i6+BwXmGr0zz+/700UJ1nMMaxEuEIjJ TtWvsXv+MVTZoXrSaW5BGHpOL4bITqKdavekp9XaKfbReV2RbSlZhVQq3q4AI0Z8 wuiglvem3TgX1fH93yOUMF5roHbPjGvPm7NKG2mXPbPh8UBK31nIbAkzJpVSf6Qg g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=fm3; bh=SsurbYtu33OKtu+7SUo3w59RA1bHXwj50BS2Kok1M N0=; b=NxOe06WJ8mpY1uVl0NWCSDBU/du74J3tXVwGBzeBhj2aICctuJN7VJQzF ZlAYzk0HQbyKsWiB4qkCkJwlFSa4ne8IcbU2uszIRH7SProB9Ul0t3yS5m30EexA 5zsjZxYKc1jHeRR0Rjy0hyziGRNPmm/7TCctfCTy5qAK78+YPDJSmG56IRwUf1bE 5WnU+Vgcu9bRefRoDACGZlriLEiwYY8pR/igCvwX22CJUxRuCNfqZHcRVmnpbbc+ MD+2RUIutnEnSmDWoIqBF38enAjnn+0KdEJXbBUu2mdMSopoB2dPRd6suZlilklj q8TFGJIbhFgFmMTLpm0D4dE4wDKKQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudegledggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpefnihhn uhhspgeujhpnrhhnshhtrghmuceolhhinhhushdrihhnthgvrhhnvghtsehfrghsthhmrg hilhdrshgvqeenucggtffrrghtthgvrhhnpedtfedvtdefvdefuedukeeluddtgfdtgeeh geeljeeuvedvteekgfehjefgvdeggeenucffohhmrghinhepghhnuhdrohhrghenucevlh hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlihhnuhhsrdhi nhhtvghrnhgvthesfhgrshhtmhgrihhlrdhsvg X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id D60ABC200A4; Sun, 7 Jun 2020 07:21:04 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: Received-SPF: pass client-ip=64.147.123.20; envelope-from=linus.internet@fastmail.se; helo=wout4-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/07 07:21:06 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_H4=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-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:16558 Archived-At: Try disassembling it. I suspect the for-each is inlined, and that whatev= er is going on involves instruction explosion which means you get a lot = more optimization opportunities. =20 That difference seems large though. Try it in guile 2.2 (which shouldnt= have the same opportunities for optimization).=20 --=20 Linus Bj=C3=B6rnstam On Sun, 7 Jun 2020, at 08:27, Aleix Conchillo Flaqu=C3=A9 wrote: > Hi, >=20 > in the latest guile-json, 4.1.0. I changed some code to use > for-each+string->list. The performance seemed nice and I released it. >=20 > Christopher Lam pointed out that I could have used string-for-each ins= tead. > I made the change but the performance degraded a lot: >=20 > string-for-each: >=20 > scheme@(json parser)> ,t (->bool (scm->json-string json)) > $19 =3D #t > ;; 17.909537s real time, 18.063382s run time. 0.207281s spent in GC. >=20 > vs >=20 > for-each + string->list: >=20 > scheme@(json parser)> ,t (->bool (scm->json-string json)) > $20 =3D #t > ;; 2.998381s real time, 3.319349s run time. 0.471969s spent in GC. >=20 > string-for-each is implemented in scheme here, if Im not wrong: >=20 > http://git.savannah.gnu.org/cgit/guile.git/tree/module/rnrs/base.scm#n= 89 >=20 > string->list and for-each would use C. >=20 > Is that huge gap expected? >=20 > This is with Guile 3.0.2. >=20 > Best, >=20 > Aleix >