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?Aleix_Conchillo_Flaqu=C3=A9?= Newsgroups: gmane.lisp.guile.user Subject: Re: string-for-each vs. for-each+string->list performance Date: Sat, 6 Jun 2020 23:33:38 -0700 Message-ID: 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="24813"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sun Jun 07 08:34:05 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 1jhosf-0006LH-6L for guile-user@m.gmane-mx.org; Sun, 07 Jun 2020 08:34:05 +0200 Original-Received: from localhost ([::1]:56336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhose-0001aj-94 for guile-user@m.gmane-mx.org; Sun, 07 Jun 2020 02:34:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhosS-0001YT-Sb for guile-user@gnu.org; Sun, 07 Jun 2020 02:33:52 -0400 Original-Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]:36123) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhosS-0008LK-1I for guile-user@gnu.org; Sun, 07 Jun 2020 02:33:52 -0400 Original-Received: by mail-lj1-x22b.google.com with SMTP id a25so16604993ljp.3 for ; Sat, 06 Jun 2020 23:33:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=eevVvjiBngAgsGuEU11e4VWvnjFnB4RkvTiBYSl1sp8=; b=fk8eXFdRakNVyLM5kCfTS0bmHRzmlvV5Q4IUHXKgJSk/NPKM2fPbC8KCC2izLBRHAF WbtVTeEnvqh4L3KfTz9X5tOGvJ7JvrAwHQCcB84YWFznp0XuQ5XUtVfKnrBnxx4SQGbN BmGEZiIk/i/qKgGs9btxHcFA5cBiAIjb1VCUe84N2RUeCyJx2BxsTUaabjsGjiX+eSKI LzGMC+KFZv2iIAgVEGZDGtILLLSb+TwIJVa/nt18gzU6WWBiCIoEhekzjN/q7mCwcHzD i3va+r48cA9B0MGRJBnj8W37HYlNw5Eo61HGWT/UM60E9c3rWosGhklraiKYEwSzHfmt IYiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=eevVvjiBngAgsGuEU11e4VWvnjFnB4RkvTiBYSl1sp8=; b=uddeagSLSXQuLp+aDIYh+uQVGzWyFs4B6UPzMuTB/wERQnm52j0jQEcPkqc+jz7AH3 o3yP2PhcHDqov5zOosUoYHBsMlnIj9YXiSr/+JU2IohHSwZQA9MX9ZJnJobWiqd98GQZ U970TLXhptfUpliyb5entes2VFr1uvCmbN7Ys3b5ReEiLgJ+jIAbFhLKQAjswNxeNXX9 2CnBHHrHTmsHfwXcWmasO2C9uRHvYplQapmOUL2A0Tjj6JSp/9eGZbkAIT7+wOfijkU+ UpYROWr/yi46a1LKQFK8BnFWHQNBFpay14ur2Mc//AKKlYeNmHJfRsFck4r5xSFv6KkB qU9g== X-Gm-Message-State: AOAM531FBdG7oS/bnPPjSJIGYHz9T4HMtuEMeFUmeRKrHB8FPnRNlwXe UV4muYUd0OamM5gYmCP3O/k+oBkXOJGZ/kvLNUIdOtwy X-Google-Smtp-Source: ABdhPJwO+ZdgDaWfOGLgmts0rA9UdiR/u4kHTEdVpVugaKf8y/+/8QA4bj4i8bqSctgr2XdqxxvC8nuBDLZMjDacxVQ= X-Received: by 2002:a2e:959a:: with SMTP id w26mr7911430ljh.74.1591511629778; Sat, 06 Jun 2020 23:33:49 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::22b; envelope-from=aconchillo@gmail.com; helo=mail-lj1-x22b.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 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:16554 Archived-At: On Sat, Jun 6, 2020 at 11:27 PM Aleix Conchillo Flaqu=C3=A9 wrote: > Hi, > > 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. > > Christopher Lam pointed out that I could have used string-for-each > instead. I made the change but the performance degraded a lot: > > string-for-each: > > 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. > > vs > > for-each + string->list: > > 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. > > string-for-each is implemented in scheme here, if Im not wrong: > > http://git.savannah.gnu.org/cgit/guile.git/tree/module/rnrs/base.scm#n89 > > string->list and for-each would use C. > > Is that huge gap expected? > > This is with Guile 3.0.2. > > Forgot to mention that Chritopher also pointed out that string->list has an optimization for narrow strings: http://git.savannah.gnu.org/cgit/guile.git/tree/libguile/srfi-13.c#n294 which means it doesn't use string_ref where the scheme code has to do it. So, it might be due to this? Aleix