From unknown Wed Sep 10 13:55:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12033: format should be faster Resent-From: nalaginrut Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 23 Jul 2012 13:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 12033 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 12033@debbugs.gnu.org X-Debbugs-Original-To: bug-guile@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.134305166819216 (code B ref -1); Mon, 23 Jul 2012 13:55:02 +0000 Received: (at submit) by debbugs.gnu.org; 23 Jul 2012 13:54:28 +0000 Received: from localhost ([127.0.0.1]:59976 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1StJ5f-0004zo-MS for submit@debbugs.gnu.org; Mon, 23 Jul 2012 09:54:28 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57002) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1StBxk-0007vf-HQ for submit@debbugs.gnu.org; Mon, 23 Jul 2012 02:17:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1StBrP-0004cr-EK for submit@debbugs.gnu.org; Mon, 23 Jul 2012 02:11:16 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:44013) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StBrP-0004cn-Bh for submit@debbugs.gnu.org; Mon, 23 Jul 2012 02:11:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StBrO-0000ej-MB for bug-guile@gnu.org; Mon, 23 Jul 2012 02:11:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1StBrN-0004cd-ST for bug-guile@gnu.org; Mon, 23 Jul 2012 02:11:14 -0400 Received: from mail-bk0-f41.google.com ([209.85.214.41]:53825) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StBrN-0004cY-MT for bug-guile@gnu.org; Mon, 23 Jul 2012 02:11:13 -0400 Received: by bkcjc3 with SMTP id jc3so4604145bkc.0 for ; Sun, 22 Jul 2012 23:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:date:organization:content-type:x-mailer :content-transfer-encoding:mime-version; bh=fdd4wObb5kbC+kyecOKrggU0sdegPQ/JFG8OSCD7cW8=; b=gzI8hU94SUQkZ813P2GxOh2pYGF5T4ocDvMvVpHwo6f1Eq4p9Nk1VBqABU/LhUVCR0 C4WJxYp5mmdlnz8bjnwDQc+qQ6oTk+m6DJWNfMgZ3GoRTuXp6+kH5KV0soVGXCRsd36P kKbMdtVDcjJ0iOW3MS9DfoRoQDUpvXO4Fh+Ubn3m0yFqHTth7ekaIOQCdzzWHNjA/28K kNLdKdGIqePtf0tftAmC7wTSVKRXYQenNBCEBFuvtbAtQOwB35QkTjYoWsXDwh1sskUY LoQC8Q2gAP9+JDg/IzH4jygB9PZ0c7ZNF1wsKBZ7xx3//3/neJA/WAlBFtOWkX+AGKkM Iwgw== Received: by 10.204.128.202 with SMTP id l10mr6881263bks.127.1343023872606; Sun, 22 Jul 2012 23:11:12 -0700 (PDT) Received: from [147.2.147.112] ([61.14.130.226]) by mx.google.com with ESMTPS id n5sm5976534bkv.14.2012.07.22.23.11.09 (version=SSLv3 cipher=OTHER); Sun, 22 Jul 2012 23:11:11 -0700 (PDT) Message-ID: <1343023866.4060.12.camel@Renee-SUSE.suse> From: nalaginrut Date: Mon, 23 Jul 2012 14:11:06 +0800 Organization: HFG Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.118.235.17 X-Spam-Score: -6.1 (------) X-Mailman-Approved-At: Mon, 23 Jul 2012 09:54:25 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) Our "format" is rather slow, can we make it faster? I can only output strings with display if I need an faster program, which is not so elegant. From unknown Wed Sep 10 13:55:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12033: format should be faster Resent-From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 18 Aug 2012 22:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12033 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: nalaginrut Cc: 12033@debbugs.gnu.org Received: via spool by 12033-submit@debbugs.gnu.org id=B12033.13453283818777 (code B ref 12033); Sat, 18 Aug 2012 22:20:02 +0000 Received: (at 12033) by debbugs.gnu.org; 18 Aug 2012 22:19:41 +0000 Received: from localhost ([127.0.0.1]:37914 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T2rMq-0002HW-PV for submit@debbugs.gnu.org; Sat, 18 Aug 2012 18:19:40 -0400 Received: from xanadu.aquilenet.fr ([88.191.123.111]:40426) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T2rMo-0002HO-L7 for 12033@debbugs.gnu.org; Sat, 18 Aug 2012 18:19:39 -0400 Received: from localhost (localhost [127.0.0.1]) by xanadu.aquilenet.fr (Postfix) with ESMTP id A0E8C8EF3; Sun, 19 Aug 2012 00:19:32 +0200 (CEST) Received: from xanadu.aquilenet.fr ([127.0.0.1]) by localhost (xanadu.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IJH6IG5YGR6C; Sun, 19 Aug 2012 00:19:32 +0200 (CEST) Received: from pluto (reverse-83.fdn.fr [80.67.176.83]) by xanadu.aquilenet.fr (Postfix) with ESMTPSA id 2FF188EBC; Sun, 19 Aug 2012 00:19:32 +0200 (CEST) From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <1343023866.4060.12.camel@Renee-SUSE.suse> Date: Sun, 19 Aug 2012 00:19:31 +0200 In-Reply-To: <1343023866.4060.12.camel@Renee-SUSE.suse> (nalaginrut@gmail.com's message of "Mon, 23 Jul 2012 14:11:06 +0800") Message-ID: <87393jkfm4.fsf@gnu.org> User-Agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.2 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.2 (-) Hi! nalaginrut skribis: > Our "format" is rather slow, What makes you say so? Did you make sure that the output port you=E2=80=99re writing to is buffered (this is not the case by default!)? See =E2=80=98setvbuf=E2=80=99. > can we make it faster? I can only output strings with display if I > need an faster program, which is not so elegant. Until (ice-9 format) is loaded, =E2=80=98format=E2=80=99 is an alias for =E2=80=98simple-format=E2=80=99, which is implemented in C, less capable bu= t faster than (ice-9 format). Perhaps that=E2=80=99s usable for your use case? Thanks, Ludo=E2=80=99. From unknown Wed Sep 10 13:55:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12033: format should be faster Resent-From: nalaginrut Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 20 Aug 2012 06:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12033 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 12033@debbugs.gnu.org Received: via spool by 12033-submit@debbugs.gnu.org id=B12033.134544407626100 (code B ref 12033); Mon, 20 Aug 2012 06:28:02 +0000 Received: (at 12033) by debbugs.gnu.org; 20 Aug 2012 06:27:56 +0000 Received: from localhost ([127.0.0.1]:39245 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3LSt-0006mu-CA for submit@debbugs.gnu.org; Mon, 20 Aug 2012 02:27:55 -0400 Received: from mail-we0-f172.google.com ([74.125.82.172]:60483) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3LSr-0006mn-6j for 12033@debbugs.gnu.org; Mon, 20 Aug 2012 02:27:54 -0400 Received: by weyu54 with SMTP id u54so3824745wey.3 for <12033@debbugs.gnu.org>; Sun, 19 Aug 2012 23:27:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :organization:content-type:x-mailer:content-transfer-encoding :mime-version; bh=Dt5YNPOS99qyQix7UP1KVAuLBKVc1XoZUEDyd3/NCDc=; b=Kref6/k3wkOiocXsT+ngkHpQNreFELXb4gOjH1kQInhdUmYK/mbDNE+JsB1k2NMm+4 8JgM02zhwtsPj9y+XlADUtv3KMGV8y7WVqkp5JPhTQofRkFB/I8mnQY+ZFkvfnnqO975 rUip3/GkS1/TE6sub2/qpf1MVDpMLM2FC+QXuzaac9n0EToPWXgwjKzBPCA0cAKteJaK UY7grAnpDjCrdpmaPwf6Fz2hMkb3IXmn+nJ02I6+qFn5pXrNmZI+ILWg42oTiE9l/iyv 4ugPlBDa4SH3v6na+NzEuAWTltL8psqlqQtNbEgZOf2nqXXheo+IUgf2jIIiaho9FcxR Z1Kg== Received: by 10.180.106.137 with SMTP id gu9mr26135840wib.20.1345444060554; Sun, 19 Aug 2012 23:27:40 -0700 (PDT) Received: from [147.2.147.112] ([61.14.130.226]) by mx.google.com with ESMTPS id l6sm26405742wiz.4.2012.08.19.23.27.37 (version=SSLv3 cipher=OTHER); Sun, 19 Aug 2012 23:27:39 -0700 (PDT) Message-ID: <1345444055.5141.52.camel@Renee-SUSE.suse> From: nalaginrut Date: Mon, 20 Aug 2012 14:27:35 +0800 In-Reply-To: <87393jkfm4.fsf@gnu.org> References: <1343023866.4060.12.camel@Renee-SUSE.suse> <87393jkfm4.fsf@gnu.org> Organization: HFG Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3 Content-Transfer-Encoding: 8bit Mime-Version: 1.0 X-Spam-Score: -2.6 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) On Sun, 2012-08-19 at 00:19 +0200, Ludovic Courtès wrote: > Hi! > > nalaginrut skribis: > > > Our "format" is rather slow, > > What makes you say so? > > Did you make sure that the output port you’re writing to is buffered > (this is not the case by default!)? See ‘setvbuf’. > OK, yes, I assumed the port will be buffered in default. Should I set stdin/stdout(current-input-port/current-output-port) as buffered each time? But in my case, there's only current-output-port. And I set it as buffered, the result is the same. > > can we make it faster? I can only output strings with display if I > > need an faster program, which is not so elegant. > > Until (ice-9 format) is loaded, ‘format’ is an alias for > ‘simple-format’, which is implemented in C, less capable but faster than > (ice-9 format). Perhaps that’s usable for your use case? > But I never use (ice-9 format). There's ~15s difference between "display" and "format" in my laptop. ---------------code-1------------------ (define (main . args) (let* ((ll ((@ (srfi srfi-1) iota) (read) 1)) (len (length ll)) (m (1- (/ len 2)))) (display len)(newline) (let lp((a (list-head ll (1+ m))) (b (list-tail ll (1+ m))) (n 1)) (and (< n len) (for-each (lambda (x y) (display x)(display " ")(display y)(display " ")) a b)(newline) (lp (append (list 1 (car b)) (cdr a)) (append (cdr b) (list (list-ref a m))) (1+ n)))))) -----------------end------------------- --------------code-2------------------- (define (main . args) (let* ((ll ((@ (srfi srfi-1) iota) (read) 1)) (len (length ll)) (m (1- (/ len 2)))) (display len)(newline) (let lp((a (list-head ll (1+ m))) (b (list-tail ll (1+ m))) (n 1)) (and (< n len) (for-each (lambda (x y) (format #t "~a ~a~%" x y)) a b) (lp (append (list 1 (car b)) (cdr a)) (append (cdr b) (list (list-ref a m))) (1+ n)))))) ---------------end--------------------- time { echo 6000 | ./test 1>/dev/null ;} Code-1 is 0m30.326s Code-2 is 0m45.310s PS: Please use 6000 at least, or it's size is not representative. > Thanks, > Ludo’. From unknown Wed Sep 10 13:55:58 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.428 (Entity 5.428) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: nalaginrut Subject: bug#12033: closed (Re: bug#12033: format should be faster) Message-ID: References: <878vd9i651.fsf@gnu.org> <1343023866.4060.12.camel@Renee-SUSE.suse> X-Gnu-PR-Message: they-closed 12033 X-Gnu-PR-Package: guile Reply-To: 12033@debbugs.gnu.org Date: Mon, 20 Aug 2012 21:52:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1345499522-18910-1" This is a multi-part message in MIME format... ------------=_1345499522-18910-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #12033: format should be faster which was filed against the guile package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 12033@debbugs.gnu.org. --=20 12033: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D12033 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1345499522-18910-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 12033-done) by debbugs.gnu.org; 20 Aug 2012 21:52:00 +0000 Received: from localhost ([127.0.0.1]:40505 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3ZtA-0004uo-9c for submit@debbugs.gnu.org; Mon, 20 Aug 2012 17:52:00 -0400 Received: from xanadu.aquilenet.fr ([88.191.123.111]:58978) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3Zt7-0004ud-O4 for 12033-done@debbugs.gnu.org; Mon, 20 Aug 2012 17:51:59 -0400 Received: from localhost (localhost [127.0.0.1]) by xanadu.aquilenet.fr (Postfix) with ESMTP id 3B2D591B3; Mon, 20 Aug 2012 23:51:40 +0200 (CEST) Received: from xanadu.aquilenet.fr ([127.0.0.1]) by localhost (xanadu.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FJZ1xhyMlo+N; Mon, 20 Aug 2012 23:51:40 +0200 (CEST) Received: from pluto (reverse-83.fdn.fr [80.67.176.83]) by xanadu.aquilenet.fr (Postfix) with ESMTPSA id 759468E92; Mon, 20 Aug 2012 23:51:39 +0200 (CEST) From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) To: nalaginrut Subject: Re: bug#12033: format should be faster References: <1343023866.4060.12.camel@Renee-SUSE.suse> <87393jkfm4.fsf@gnu.org> <1345444055.5141.52.camel@Renee-SUSE.suse> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 4 Fructidor an 220 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu Date: Mon, 20 Aug 2012 23:51:38 +0200 In-Reply-To: <1345444055.5141.52.camel@Renee-SUSE.suse> (nalaginrut@gmail.com's message of "Mon, 20 Aug 2012 14:27:35 +0800") Message-ID: <878vd9i651.fsf@gnu.org> User-Agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.2 (-) X-Debbugs-Envelope-To: 12033-done Cc: 12033-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.2 (-) Hi, Here=E2=80=99s slightly modified code: --8<---------------cut here---------------start------------->8--- (use-modules (ice-9 time)) (define (d len) (let* ((ll ((@ (srfi srfi-1) iota) len 1)) (m (1- (/ len 2)))) (time (with-output-to-port (%make-void-port "w") (lambda () (let lp ((a (list-head ll (1+ m))) (b (list-tail ll (1+ m))) (n 1)) (and (< n len) (for-each (lambda (x y) (display x)(display " ")(display y) (display " ")) a b) (newline) (lp (append (list 1 (car b)) (cdr a)) (append (cdr b) (list (list-ref a m))) (1+ n))))))))) (define (f len) (let* ((ll ((@ (srfi srfi-1) iota) len 1)) (m (1- (/ len 2)))) (time (with-output-to-port (%make-void-port "w") (lambda () (let lp ((a (list-head ll (1+ m))) (b (list-tail ll (1+ m))) (n 1)) (and (< n len) (for-each (lambda (x y) (simple-format #t "~a ~a~%" x y)) a b) (lp (append (list 1 (car b)) (cdr a)) (append (cdr b) (list (list-ref a m))) (1+ n))))))))) --8<---------------cut here---------------end--------------->8--- Here=E2=80=99s the difference I have: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> (f 4000) clock utime stime cutime cstime gctime 8.37 8.35 0.00 0.00 0.00 0.56 $9 =3D #f scheme@(guile-user)> (d 4000) clock utime stime cutime cstime gctime 6.37 6.35 0.00 0.00 0.00 0.05 $10 =3D #f --8<---------------cut here---------------end--------------->8--- So =E2=80=98simple-format=E2=80=99 is 30% slower than the series of =E2=80= =98display=E2=80=99 etc. calls. A profile from Callgrind shows that ~22% of the program with =E2=80=98f=E2= =80=99 is spent in =E2=80=98scm_c_substring=E2=80=99 and the allocations it entails. Commit b908768a7ec79f78def344c464186a51f55b69e8 in stable-2.0 changes the situation like this: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> (d 4000) clock utime stime cutime cstime gctime 6.46 6.45 0.00 0.00 0.00 0.08 $3 =3D #f scheme@(guile-user)> (f 4000) clock utime stime cutime cstime gctime 5.47 5.44 0.01 0.00 0.00 0.25 $4 =3D #f --8<---------------cut here---------------end--------------->8--- Now, =E2=80=98simple-format=E2=80=99 is 15% faster than =E2=80=98display=E2= =80=99. Hurray! ;-) So, I=E2=80=99m closing this bug. Note that (ice-9 format) is an order of magnitude slower, though: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> (f 4000) clock utime stime cutime cstime gctime 260.14 258.94 0.51 0.00 0.00 63.19 $1 =3D #f --8<---------------cut here---------------end--------------->8--- Admittedly, this should be fixed, but that=E2=80=99s another story... Thanks, Ludo=E2=80=99. ------------=_1345499522-18910-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 23 Jul 2012 13:54:28 +0000 Received: from localhost ([127.0.0.1]:59976 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1StJ5f-0004zo-MS for submit@debbugs.gnu.org; Mon, 23 Jul 2012 09:54:28 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57002) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1StBxk-0007vf-HQ for submit@debbugs.gnu.org; Mon, 23 Jul 2012 02:17:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1StBrP-0004cr-EK for submit@debbugs.gnu.org; Mon, 23 Jul 2012 02:11:16 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:44013) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StBrP-0004cn-Bh for submit@debbugs.gnu.org; Mon, 23 Jul 2012 02:11:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StBrO-0000ej-MB for bug-guile@gnu.org; Mon, 23 Jul 2012 02:11:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1StBrN-0004cd-ST for bug-guile@gnu.org; Mon, 23 Jul 2012 02:11:14 -0400 Received: from mail-bk0-f41.google.com ([209.85.214.41]:53825) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StBrN-0004cY-MT for bug-guile@gnu.org; Mon, 23 Jul 2012 02:11:13 -0400 Received: by bkcjc3 with SMTP id jc3so4604145bkc.0 for ; Sun, 22 Jul 2012 23:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:date:organization:content-type:x-mailer :content-transfer-encoding:mime-version; bh=fdd4wObb5kbC+kyecOKrggU0sdegPQ/JFG8OSCD7cW8=; b=gzI8hU94SUQkZ813P2GxOh2pYGF5T4ocDvMvVpHwo6f1Eq4p9Nk1VBqABU/LhUVCR0 C4WJxYp5mmdlnz8bjnwDQc+qQ6oTk+m6DJWNfMgZ3GoRTuXp6+kH5KV0soVGXCRsd36P kKbMdtVDcjJ0iOW3MS9DfoRoQDUpvXO4Fh+Ubn3m0yFqHTth7ekaIOQCdzzWHNjA/28K kNLdKdGIqePtf0tftAmC7wTSVKRXYQenNBCEBFuvtbAtQOwB35QkTjYoWsXDwh1sskUY LoQC8Q2gAP9+JDg/IzH4jygB9PZ0c7ZNF1wsKBZ7xx3//3/neJA/WAlBFtOWkX+AGKkM Iwgw== Received: by 10.204.128.202 with SMTP id l10mr6881263bks.127.1343023872606; Sun, 22 Jul 2012 23:11:12 -0700 (PDT) Received: from [147.2.147.112] ([61.14.130.226]) by mx.google.com with ESMTPS id n5sm5976534bkv.14.2012.07.22.23.11.09 (version=SSLv3 cipher=OTHER); Sun, 22 Jul 2012 23:11:11 -0700 (PDT) Message-ID: <1343023866.4060.12.camel@Renee-SUSE.suse> Subject: format should be faster From: nalaginrut To: bug-guile@gnu.org Date: Mon, 23 Jul 2012 14:11:06 +0800 Organization: HFG Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.118.235.17 X-Spam-Score: -6.1 (------) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 23 Jul 2012 09:54:25 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) Our "format" is rather slow, can we make it faster? I can only output strings with display if I need an faster program, which is not so elegant. ------------=_1345499522-18910-1-- From unknown Wed Sep 10 13:55:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12033: closed (Re: bug#12033: format should be faster) Resent-From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 20 Aug 2012 22:38:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12033 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 12033@debbugs.gnu.org Cc: nalaginrut Received: via spool by 12033-submit@debbugs.gnu.org id=B12033.134550227823080 (code B ref 12033); Mon, 20 Aug 2012 22:38:03 +0000 Received: (at 12033) by debbugs.gnu.org; 20 Aug 2012 22:37:58 +0000 Received: from localhost ([127.0.0.1]:40569 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3abc-00060D-T6 for submit@debbugs.gnu.org; Mon, 20 Aug 2012 18:37:57 -0400 Received: from xanadu.aquilenet.fr ([88.191.123.111]:38024) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3abY-0005zy-OB for 12033@debbugs.gnu.org; Mon, 20 Aug 2012 18:37:53 -0400 Received: from localhost (localhost [127.0.0.1]) by xanadu.aquilenet.fr (Postfix) with ESMTP id A38D78FF0; Tue, 21 Aug 2012 00:37:36 +0200 (CEST) Received: from xanadu.aquilenet.fr ([127.0.0.1]) by localhost (xanadu.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rg3H1DI9hSt6; Tue, 21 Aug 2012 00:37:36 +0200 (CEST) Received: from pluto (reverse-83.fdn.fr [80.67.176.83]) by xanadu.aquilenet.fr (Postfix) with ESMTPSA id 174FE8F09; Tue, 21 Aug 2012 00:37:36 +0200 (CEST) From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <878vd9i651.fsf@gnu.org> <1343023866.4060.12.camel@Renee-SUSE.suse> Date: Tue, 21 Aug 2012 00:37:35 +0200 In-Reply-To: (GNU bug Tracking System's message of "Mon, 20 Aug 2012 21:52:02 +0000") Message-ID: <87boi5gpg0.fsf@gnu.org> User-Agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.2 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.2 (-) I wrote: > Note that (ice-9 format) is an order of magnitude slower, though: > > scheme@(guile-user)> (f 4000) > clock utime stime cutime cstime gctime > 260.14 258.94 0.51 0.00 0.00 63.19 > $1 =3D #f > > Admittedly, this should be fixed, but that=E2=80=99s another story... A bit of profiling shows this: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,pr (with-output-to-port (%make-void-port "w") (lambda= () (let loop ((i 40000)) (or (zero? i) (begin (format #t "~a ~a~%" 'foo 'b= ar) (loop (1- i))))))) % cumulative self=20=20=20=20=20=20=20=20=20=20=20=20=20 time seconds seconds name 15.70 2.13 0.34 format 10.74 1.39 0.23 tilde-dispatch 10.74 0.96 0.23 call-with-output-string 7.44 0.20 0.16 # [...] Sample count: 121 Total time: 2.183744831 seconds (0.77482795 seconds in GC) --8<---------------cut here---------------end--------------->8--- Procedure #4 is =E2=80=98with-output-to-string=E2=80=99, so we can easily i= mprove that by using =E2=80=98call-with-output-string=E2=80=99 directly instead: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,pr (with-output-to-port (%make-void-port "w") (lambda= () (let loop ((i 40000)) (or (zero? i) (begin (format #t "~a ~a~%" 'foo 'b= ar) (loop (1- i))))))) % cumulative self=20=20=20=20=20=20=20=20=20=20=20=20=20 time seconds seconds name 17.39 0.56 0.28 call-with-output-string 14.13 0.24 0.23 # 13.04 1.58 0.21 format 9.78 1.27 0.16 format:format-work [...] Sample count: 92 Total time: 1.597127172 seconds (0.513423265 seconds in GC) --8<---------------cut here---------------end--------------->8--- Commit 6c9220064d987deee813cfd933d50353d14d4c0f. To be continued... Ludo=E2=80=99. From unknown Wed Sep 10 13:55:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12033: closed (Re: bug#12033: format should be faster) Resent-From: nalaginrut Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 21 Aug 2012 02:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12033 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 12033@debbugs.gnu.org Received: via spool by 12033-submit@debbugs.gnu.org id=B12033.134551748612216 (code B ref 12033); Tue, 21 Aug 2012 02:52:02 +0000 Received: (at 12033) by debbugs.gnu.org; 21 Aug 2012 02:51:26 +0000 Received: from localhost ([127.0.0.1]:40731 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3eYv-0003Ay-KV for submit@debbugs.gnu.org; Mon, 20 Aug 2012 22:51:25 -0400 Received: from mail-we0-f172.google.com ([74.125.82.172]:35244) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3eYs-0003Aq-P2 for 12033@debbugs.gnu.org; Mon, 20 Aug 2012 22:51:23 -0400 Received: by weyu54 with SMTP id u54so4434575wey.3 for <12033@debbugs.gnu.org>; Mon, 20 Aug 2012 19:51:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :organization:content-type:x-mailer:content-transfer-encoding :mime-version; bh=QRfMrTb2bfwOT9z3YT0fD+KWC6lbxtbxWhxf7KuHayQ=; b=WphR/EszRroKD4Hjla4orbIF/wtbkGtSQJKSQsVoiH89RUiZSOxH2L9ftio5+IjERj O6oTj5HAhyvidtzgNUn40x4ACkxw1zHyNjcOio92FB0slpzNRDQOxj6MkubvN1TiuYaU +mK2wUi9F1+pMmcBaoRYYK6DrxvASCJaEA2rgHK+RTTm2ouCWsowR0VmVWs/NF87OuuB 38pzEk5bu1qGie9VHIq0BN+wgHshFmCA3NjXMouaKDKnFnzrMchC5AIc5VLBNLdkFztX SURwZU8VutrEDaj/ra53z51m81y1bIDmtiOgBQjJOYkRCly5l0MtmjFeAxGka00YIS88 WeJQ== Received: by 10.180.106.137 with SMTP id gu9mr33821620wib.20.1345517465003; Mon, 20 Aug 2012 19:51:05 -0700 (PDT) Received: from [147.2.147.112] ([61.14.130.226]) by mx.google.com with ESMTPS id ck9sm575303wib.2.2012.08.20.19.51.02 (version=SSLv3 cipher=OTHER); Mon, 20 Aug 2012 19:51:04 -0700 (PDT) Message-ID: <1345517459.5141.62.camel@Renee-SUSE.suse> From: nalaginrut Date: Tue, 21 Aug 2012 10:50:59 +0800 In-Reply-To: <87boi5gpg0.fsf@gnu.org> References: <878vd9i651.fsf@gnu.org> <1343023866.4060.12.camel@Renee-SUSE.suse> <87boi5gpg0.fsf@gnu.org> Organization: HFG Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3 Content-Transfer-Encoding: 8bit Mime-Version: 1.0 X-Spam-Score: -2.6 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) On Tue, 2012-08-21 at 00:37 +0200, Ludovic Courtès wrote: > I wrote: > > > Note that (ice-9 format) is an order of magnitude slower, though: > > > > scheme@(guile-user)> (f 4000) > > clock utime stime cutime cstime gctime > > 260.14 258.94 0.51 0.00 0.00 63.19 > > $1 = #f > > > > Admittedly, this should be fixed, but that’s another story... > > A bit of profiling shows this: > > --8<---------------cut here---------------start------------->8--- > scheme@(guile-user)> ,pr (with-output-to-port (%make-void-port "w") (lambda () (let loop ((i 40000)) (or (zero? i) (begin (format #t "~a ~a~%" 'foo 'bar) (loop (1- i))))))) > % cumulative self > time seconds seconds name > 15.70 2.13 0.34 format > 10.74 1.39 0.23 tilde-dispatch > 10.74 0.96 0.23 call-with-output-string > 7.44 0.20 0.16 # > [...] hi Ludo! I recall something about tilde-displatch since you mentioned it. A guy discussed the efficiency of format with me years ago, I talked with Andy, but then I forgot it: --------------------code------------------- scheme@(guile-user)> ,profile (let lp ((i 10000)) (if (> i 0) (begin (format #f "0x~2'0x, 0x~2'0x, 0x~2'0x" i i i) (lp (1- i))))) % cumulative self time seconds seconds name 22.58 0.56 0.23 tilde-dispatch 12.90 1.00 0.13 format 12.90 0.13 0.13 number->string 8.06 0.13 0.08 format:out-char 4.84 0.80 0.05 format:format-work --------------------end------------------- In this case, we tried "0x~2'0x" and it's so slow that we can't bare it. i=10000 is fast, but we need (* 600 80000) And we found that "tilde-dispatch" cost too much. Is there any possible to optimize it? > Sample count: 121 > Total time: 2.183744831 seconds (0.77482795 seconds in GC) > --8<---------------cut here---------------end--------------->8--- > > Procedure #4 is ‘with-output-to-string’, so we can easily improve that > by using ‘call-with-output-string’ directly instead: > > --8<---------------cut here---------------start------------->8--- > scheme@(guile-user)> ,pr (with-output-to-port (%make-void-port "w") (lambda () (let loop ((i 40000)) (or (zero? i) (begin (format #t "~a ~a~%" 'foo 'bar) (loop (1- i))))))) > % cumulative self > time seconds seconds name > 17.39 0.56 0.28 call-with-output-string > 14.13 0.24 0.23 # > 13.04 1.58 0.21 format > 9.78 1.27 0.16 format:format-work > [...] > Sample count: 92 > Total time: 1.597127172 seconds (0.513423265 seconds in GC) > --8<---------------cut here---------------end--------------->8--- > > Commit 6c9220064d987deee813cfd933d50353d14d4c0f. > > To be continued... > > Ludo’. From unknown Wed Sep 10 13:55:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12033: closed (Re: bug#12033: format should be faster) Resent-From: Noah Lavine Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 21 Aug 2012 03:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12033 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: nalaginrut Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , 12033@debbugs.gnu.org Received: via spool by 12033-submit@debbugs.gnu.org id=B12033.134551804513051 (code B ref 12033); Tue, 21 Aug 2012 03:01:02 +0000 Received: (at 12033) by debbugs.gnu.org; 21 Aug 2012 03:00:45 +0000 Received: from localhost ([127.0.0.1]:40741 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3ehx-0003OR-1g for submit@debbugs.gnu.org; Mon, 20 Aug 2012 23:00:45 -0400 Received: from mail-ob0-f172.google.com ([209.85.214.172]:43171) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3eht-0003OH-LP for 12033@debbugs.gnu.org; Mon, 20 Aug 2012 23:00:43 -0400 Received: by obbwc20 with SMTP id wc20so11029284obb.3 for <12033@debbugs.gnu.org>; Mon, 20 Aug 2012 20:00:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=YWQ/c5PWbEnw9BtKoVdfhfkJ10Zj3BDGtc9NKsH6arI=; b=gp4BDxRTAdA25TWjKuslLsJUAKrsDR18L1PIaeV19qkCNPYANTRvVHSV47vhSUAq5f vgrZxYtIPOQ+gQlgiJK3FviSyMqW8ZSJW9AifYPJkhRdGtpZrTr6MdXqdE0xirUBUdyS qKHnsCyCyGZ6xKO7JxF3s5AD08wDIVk9U8eSQ/KO2vYjeUSYiWVRELE6u9yH6FiqkpUq dN3mx05kQO+vUWdd/5GiURGq6aViwT3K5BaaW34MRNAQFVHAHwMwfApJJAVG2yrI3syM 0YP/mn8YJbx+T6IuoRsw8F6vjfzZVWeyVHBCJ2Q+qtyNS9vq3ef36uIWhHUP5N8+3JTr Qu5A== MIME-Version: 1.0 Received: by 10.60.30.229 with SMTP id v5mr6818119oeh.130.1345518024414; Mon, 20 Aug 2012 20:00:24 -0700 (PDT) Received: by 10.76.167.197 with HTTP; Mon, 20 Aug 2012 20:00:24 -0700 (PDT) In-Reply-To: <1345517459.5141.62.camel@Renee-SUSE.suse> References: <878vd9i651.fsf@gnu.org> <1343023866.4060.12.camel@Renee-SUSE.suse> <87boi5gpg0.fsf@gnu.org> <1345517459.5141.62.camel@Renee-SUSE.suse> Date: Mon, 20 Aug 2012 23:00:24 -0400 X-Google-Sender-Auth: qoT8qTKc0olFvwt9f8vGizKYtjU Message-ID: From: Noah Lavine Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.3 (--) Hello, > --------------------code------------------- > scheme@(guile-user)> ,profile (let lp ((i 10000)) (if (> i 0) (begin > (format #f "0x~2'0x, 0x~2'0x, 0x~2'0x" i i i) (lp (1- i))))) > % cumulative self > time seconds seconds name > 22.58 0.56 0.23 tilde-dispatch > 12.90 1.00 0.13 format > 12.90 0.13 0.13 number->string > 8.06 0.13 0.08 format:out-char > 4.84 0.80 0.05 format:format-work > --------------------end------------------- > > In this case, we tried "0x~2'0x" and it's so slow that we can't bare it. > i=10000 is fast, but we need (* 600 80000) > And we found that "tilde-dispatch" cost too much. Is there any possible > to optimize it? It seems clear that in this case, Guile "should" know how to dispatch on the format string just once, outside of the loop, instead of doing it in every iteration. What do people think of declaring format as a macro? That wouldn't help instances of format that have a variable format string, but I bet that's a lot less common than this case. Noah From unknown Wed Sep 10 13:55:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12033: closed (Re: bug#12033: format should be faster) Resent-From: Ian Price Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 21 Aug 2012 03:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12033 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Noah Lavine Cc: 12033@debbugs.gnu.org Received: via spool by 12033-submit@debbugs.gnu.org id=B12033.134552000315813 (code B ref 12033); Tue, 21 Aug 2012 03:34:02 +0000 Received: (at 12033) by debbugs.gnu.org; 21 Aug 2012 03:33:23 +0000 Received: from localhost ([127.0.0.1]:40766 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3fDW-00046y-PG for submit@debbugs.gnu.org; Mon, 20 Aug 2012 23:33:23 -0400 Received: from mail-wg0-f46.google.com ([74.125.82.46]:48504) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3fDU-00046r-Or for 12033@debbugs.gnu.org; Mon, 20 Aug 2012 23:33:21 -0400 Received: by wgbdq10 with SMTP id dq10so5280829wgb.15 for <12033@debbugs.gnu.org>; Mon, 20 Aug 2012 20:33:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=TIYKA2qZYGaVfPr3YEsb2TQak5Tl9cyRmqA/H3kfk8s=; b=DAyFh9YK56YTNq3YAEJKXxi7UAXu4bTXsUQzgxMnYXHgeuL4HA0DJrZwLzgXc5hHC9 hWbDzlr5giNIX3lza+vw3NdSrINAKez3S8J+Hq6RhDEC77t86PrUawVXg36D/k1rXn3o YLLpsz2brDjE2Ztsby3Lg0NdUTlNYKL7PQi54mg1oARUXfE/5a9ToVPbn/1Ytk6OUXY1 zQ1HPZ6H0mKeH1/uK9oypInlVBaOvkg/1MgM5cdgei7jjYA1Pb/W4Nj77e6RAia1to71 1P1HTkjQfRI7id1l+Z3aDB59f3/+xfUy0wha/SwxR23DI7A7ePTz+MRXqjhyRMW0X9oS YVlQ== Received: by 10.180.100.37 with SMTP id ev5mr34211892wib.5.1345519983228; Mon, 20 Aug 2012 20:33:03 -0700 (PDT) Received: from Kagami.home (host86-182-156-79.range86-182.btcentralplus.com. [86.182.156.79]) by mx.google.com with ESMTPS id eu4sm31382853wib.2.2012.08.20.20.33.00 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 20 Aug 2012 20:33:02 -0700 (PDT) From: Ian Price References: <878vd9i651.fsf@gnu.org> <1343023866.4060.12.camel@Renee-SUSE.suse> <87boi5gpg0.fsf@gnu.org> <1345517459.5141.62.camel@Renee-SUSE.suse> Date: Tue, 21 Aug 2012 04:32:11 +0100 In-Reply-To: (Noah Lavine's message of "Mon, 20 Aug 2012 23:00:24 -0400") Message-ID: <87a9xosyx0.fsf@Kagami.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.3 (--) Noah Lavine writes: > It seems clear that in this case, Guile "should" know how to dispatch > on the format string just once, outside of the loop, instead of doing > it in every iteration. What do people think of declaring format as a > macro? That wouldn't help instances of format that have a variable > format string, but I bet that's a lot less common than this case. Makes sense to me, though I'm not quite sure how that plays with (ice-9 format)'s side-effecting of the existing format binding. Though it was meant as a toy, I wrote https://gist.github.com/3167775 ages ago, along similar lines to this. -- Ian Price -- shift-reset.com "Programming is like pinball. The reward for doing it well is the opportunity to do it again" - from "The Wizardy Compiled" From unknown Wed Sep 10 13:55:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12033: closed (Re: bug#12033: format should be faster) Resent-From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 21 Aug 2012 11:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12033 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Noah Lavine Cc: 12033@debbugs.gnu.org, nalaginrut Received: via spool by 12033-submit@debbugs.gnu.org id=B12033.134554907328312 (code B ref 12033); Tue, 21 Aug 2012 11:38:01 +0000 Received: (at 12033) by debbugs.gnu.org; 21 Aug 2012 11:37:53 +0000 Received: from localhost ([127.0.0.1]:41070 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3mmO-0007Ma-M2 for submit@debbugs.gnu.org; Tue, 21 Aug 2012 07:37:52 -0400 Received: from xanadu.aquilenet.fr ([88.191.123.111]:56569) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3mmM-0007MS-7Z for 12033@debbugs.gnu.org; Tue, 21 Aug 2012 07:37:51 -0400 Received: from localhost (localhost [127.0.0.1]) by xanadu.aquilenet.fr (Postfix) with ESMTP id 6852791FC; Tue, 21 Aug 2012 13:37:30 +0200 (CEST) Received: from xanadu.aquilenet.fr ([127.0.0.1]) by localhost (xanadu.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sGGZo7c4MU9x; Tue, 21 Aug 2012 13:37:30 +0200 (CEST) Received: from pluto (unknown [193.50.110.192]) by xanadu.aquilenet.fr (Postfix) with ESMTPSA id 1A61A91EE; Tue, 21 Aug 2012 13:37:30 +0200 (CEST) From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <878vd9i651.fsf@gnu.org> <1343023866.4060.12.camel@Renee-SUSE.suse> <87boi5gpg0.fsf@gnu.org> <1345517459.5141.62.camel@Renee-SUSE.suse> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 5 Fructidor an 220 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu Date: Tue, 21 Aug 2012 13:37:29 +0200 In-Reply-To: (Noah Lavine's message of "Mon, 20 Aug 2012 23:00:24 -0400") Message-ID: <87ipccqxvq.fsf@gnu.org> User-Agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.2 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.2 (-) Hi, Noah Lavine skribis: >> --------------------code------------------- >> scheme@(guile-user)> ,profile (let lp ((i 10000)) (if (> i 0) (begin >> (format #f "0x~2'0x, 0x~2'0x, 0x~2'0x" i i i) (lp (1- i))))) >> % cumulative self >> time seconds seconds name >> 22.58 0.56 0.23 tilde-dispatch >> 12.90 1.00 0.13 format >> 12.90 0.13 0.13 number->string >> 8.06 0.13 0.08 format:out-char >> 4.84 0.80 0.05 format:format-work >> --------------------end------------------- >> >> In this case, we tried "0x~2'0x" and it's so slow that we can't bare it. >> i=3D10000 is fast, but we need (* 600 80000) >> And we found that "tilde-dispatch" cost too much. Is there any possible >> to optimize it? > > It seems clear that in this case, Guile "should" know how to dispatch > on the format string just once, outside of the loop, instead of doing > it in every iteration. I think Andy would say: =E2=80=9Cinline cache!=E2=80=9D. :-) > What do people think of declaring format as a macro? That=E2=80=99s tempting, but it breaks the ABI (so not for 2.0), and it bre= aks for users who do ((@ (ice-9 format) format) #t "foo"), for instance. Maybe we could have a =E2=80=98format*=E2=80=99 macro that does as much as = possible of the dispatch at compile-time? The difficulty would be to factorize dispatch code with the =E2=80=98format=E2=80=99 procedure. Another (IMO less elegant) option would be to have an optional compiler optimization pass that would do something similar. Thanks, Ludo=E2=80=99. From unknown Wed Sep 10 13:55:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12033: closed (Re: bug#12033: format should be faster) Resent-From: Noah Lavine Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 21 Aug 2012 11:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12033 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 12033@debbugs.gnu.org, nalaginrut Received: via spool by 12033-submit@debbugs.gnu.org id=B12033.134554998329583 (code B ref 12033); Tue, 21 Aug 2012 11:54:02 +0000 Received: (at 12033) by debbugs.gnu.org; 21 Aug 2012 11:53:03 +0000 Received: from localhost ([127.0.0.1]:41079 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3n14-0007gv-5Z for submit@debbugs.gnu.org; Tue, 21 Aug 2012 07:53:02 -0400 Received: from mail-ob0-f172.google.com ([209.85.214.172]:51035) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3n11-0007gh-Lo for 12033@debbugs.gnu.org; Tue, 21 Aug 2012 07:53:01 -0400 Received: by obbwc20 with SMTP id wc20so11616902obb.3 for <12033@debbugs.gnu.org>; Tue, 21 Aug 2012 04:52:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=FmF2tH6M8Teop6AyFbxEpmUo9j1DQBSL74iUBpEyBx0=; b=y6v2WjBjQ2aro8yPYjde6rYxJg8giQhSqxtQ0zae8Bpl4e5ygQd3eqBwEt0ToK9aWo 1nxhJWkZ/epCg/vER1gHMh47gU9BCcxn9p8ZXVNlaFe5RutgUVctYZAISUG13BOYBf6k CnC7ixMn9c0z4kRL6FKfs92NsXYr3YGn3MISi3zBmjix3VmWx3idJA9cnCAf3KSrfeBP MT8md5vmJiprB+AOOsHt+j+TPhrb1sy8pH0VgaBkBq238v8TgK54lEJUjcYV0+E2lh+j ztJt3DWPPodC2oyVjv3UPgN5PNH1vc1YQsvJqEsp7lUZaDAMdipailbYRvpQjAWk5CIm g+sg== MIME-Version: 1.0 Received: by 10.182.14.36 with SMTP id m4mr13223466obc.71.1345549959445; Tue, 21 Aug 2012 04:52:39 -0700 (PDT) Received: by 10.76.167.197 with HTTP; Tue, 21 Aug 2012 04:52:39 -0700 (PDT) In-Reply-To: <87ipccqxvq.fsf@gnu.org> References: <878vd9i651.fsf@gnu.org> <1343023866.4060.12.camel@Renee-SUSE.suse> <87boi5gpg0.fsf@gnu.org> <1345517459.5141.62.camel@Renee-SUSE.suse> <87ipccqxvq.fsf@gnu.org> Date: Tue, 21 Aug 2012 07:52:39 -0400 X-Google-Sender-Auth: OuOxHC7zO_UKZMULL4uREzuTq-E Message-ID: From: Noah Lavine Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.3 (--) Hi, On Tue, Aug 21, 2012 at 7:37 AM, Ludovic Court=E8s wrote: > Hi, > > Noah Lavine skribis: > >>> --------------------code------------------- >>> scheme@(guile-user)> ,profile (let lp ((i 10000)) (if (> i 0) (begin >>> (format #f "0x~2'0x, 0x~2'0x, 0x~2'0x" i i i) (lp (1- i))))) >>> % cumulative self >>> time seconds seconds name >>> 22.58 0.56 0.23 tilde-dispatch >>> 12.90 1.00 0.13 format >>> 12.90 0.13 0.13 number->string >>> 8.06 0.13 0.08 format:out-char >>> 4.84 0.80 0.05 format:format-work >>> --------------------end------------------- >>> >>> In this case, we tried "0x~2'0x" and it's so slow that we can't bare it= . >>> i=3D10000 is fast, but we need (* 600 80000) >>> And we found that "tilde-dispatch" cost too much. Is there any possible >>> to optimize it? >> >> It seems clear that in this case, Guile "should" know how to dispatch >> on the format string just once, outside of the loop, instead of doing >> it in every iteration. > > I think Andy would say: =93inline cache!=94. :-) > >> What do people think of declaring format as a macro? > > That=92s tempting, but it breaks the ABI (so not for 2.0), and it breaks > for users who do ((@ (ice-9 format) format) #t "foo"), for instance. > > Maybe we could have a =91format*=92 macro that does as much as possible o= f > the dispatch at compile-time? The difficulty would be to factorize > dispatch code with the =91format=92 procedure. What I was hoping to do is have a macro that is also identifier-syntax, so if format is used in a way that can't be macroexpanded, it falls back to the procedure. I think I've seen an example of this before, but I'm not sure where. > Another (IMO less elegant) option would be to have an optional compiler > optimization pass that would do something similar. Yes, but I agree it's less elegant, because it splits the format logic across two pieces of code, and puts some of it in the compiler, which shouldn't really have to know about it. This is a problem that I'd like to solve more generally, by letting functions tell the compiler how to optimize themselves, but that's a big project, and using a macro seemed like a much simpler way to get the same effect here. However, I wonder if the partial evaluator would actually solve this problem if it knew how to do cross-module inlining. That's another big project, but it could be a way to solve this problem and keep format as a function. > Thanks, > Ludo=92. Thanks, Noah From unknown Wed Sep 10 13:55:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12033: closed (Re: bug#12033: format should be faster) Resent-From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 21 Aug 2012 13:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12033 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Noah Lavine Cc: 12033@debbugs.gnu.org, nalaginrut Received: via spool by 12033-submit@debbugs.gnu.org id=B12033.13455564666474 (code B ref 12033); Tue, 21 Aug 2012 13:42:02 +0000 Received: (at 12033) by debbugs.gnu.org; 21 Aug 2012 13:41:06 +0000 Received: from localhost ([127.0.0.1]:41227 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3ohe-0001gN-LT for submit@debbugs.gnu.org; Tue, 21 Aug 2012 09:41:06 -0400 Received: from xanadu.aquilenet.fr ([88.191.123.111]:59160) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3ohc-0001gF-DB for 12033@debbugs.gnu.org; Tue, 21 Aug 2012 09:41:05 -0400 Received: from localhost (localhost [127.0.0.1]) by xanadu.aquilenet.fr (Postfix) with ESMTP id 31E82249E; Tue, 21 Aug 2012 15:40:43 +0200 (CEST) Received: from xanadu.aquilenet.fr ([127.0.0.1]) by localhost (xanadu.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZlK0kqa05wSK; Tue, 21 Aug 2012 15:40:43 +0200 (CEST) Received: from pluto (unknown [193.50.110.192]) by xanadu.aquilenet.fr (Postfix) with ESMTPSA id E59792136; Tue, 21 Aug 2012 15:40:42 +0200 (CEST) From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <878vd9i651.fsf@gnu.org> <1343023866.4060.12.camel@Renee-SUSE.suse> <87boi5gpg0.fsf@gnu.org> <1345517459.5141.62.camel@Renee-SUSE.suse> <87ipccqxvq.fsf@gnu.org> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 5 Fructidor an 220 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu Date: Tue, 21 Aug 2012 15:40:42 +0200 In-Reply-To: (Noah Lavine's message of "Tue, 21 Aug 2012 07:52:39 -0400") Message-ID: <87obm4pdlx.fsf@gnu.org> User-Agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.2 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.2 (-) Hi, Noah Lavine skribis: > What I was hoping to do is have a macro that is also > identifier-syntax, so if format is used in a way that can't be > macroexpanded, it falls back to the procedure. I think I've seen an > example of this before, but I'm not sure where. Yes, =E2=80=98define-inlinable=E2=80=99 does that, for instance. [...] > However, I wonder if the partial evaluator would actually solve this > problem if it knew how to do cross-module inlining. That's another big > project, but it could be a way to solve this problem and keep format > as a function. If =E2=80=98format=E2=80=99 were defined with =E2=80=98define-inlinable=E2= =80=99 (which it cannot currently, because rest arguments aren=E2=80=99t supported=E2=80=93which sh= ould be fixed), then peval could specialize the =E2=80=98format=E2=80=99 code at th= e call site. I wonder how far it=E2=80=99d go, though. Ludo=E2=80=99. From unknown Wed Sep 10 13:55:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12033: closed (Re: bug#12033: format should be faster) Resent-From: Andy Wingo Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 21 Aug 2012 19:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12033 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Cc: Noah Lavine , 12033@debbugs.gnu.org, nalaginrut Received: via spool by 12033-submit@debbugs.gnu.org id=B12033.134557777914967 (code B ref 12033); Tue, 21 Aug 2012 19:37:02 +0000 Received: (at 12033) by debbugs.gnu.org; 21 Aug 2012 19:36:19 +0000 Received: from localhost ([127.0.0.1]:41940 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3uFP-0003tM-8Y for submit@debbugs.gnu.org; Tue, 21 Aug 2012 15:36:19 -0400 Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:36084 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3uFM-0003tE-EW for 12033@debbugs.gnu.org; Tue, 21 Aug 2012 15:36:17 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 723DC927A; Tue, 21 Aug 2012 15:35:55 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=I90DW5N0qHM+ g3jWnmhPYeJfdKc=; b=wsSiGCKvF4WWXgDFb9cxVqP7AESt6BNW0xSnf/r7Y+0N AiW9rHfCklP/vHqKZC+JtOg0q23SW6Zo19ArZ87Vh6Q+ZmLIjYbpr4775GGdlPjU ndvJgVfRO/Uu4rlAQb65FDaFLoZ29wufqUngX5/tyHNAGA7yKmh9SXdlVdLCM9s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=qxwJ4R jdgxmbnXUuqOf4yQj/p05TN4pI7s4GVyNudz9STwJDSbQyXnWhvp+H/l7cFSeAye qYPWmdyCIjSzxsiQdsIPEauonXG6fOIUWNULfEdmk5ZLnoDflbESjSzeXJJfwWjA yiEyfIWLt223vO6unG9grjng10nDeDemExaBk= Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 603239279; Tue, 21 Aug 2012 15:35:55 -0400 (EDT) Received: from badger (unknown [89.131.176.233]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id CB5809278; Tue, 21 Aug 2012 15:35:54 -0400 (EDT) From: Andy Wingo References: <878vd9i651.fsf@gnu.org> <1343023866.4060.12.camel@Renee-SUSE.suse> <87boi5gpg0.fsf@gnu.org> <1345517459.5141.62.camel@Renee-SUSE.suse> <87ipccqxvq.fsf@gnu.org> Date: Tue, 21 Aug 2012 21:35:46 +0200 In-Reply-To: <87ipccqxvq.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Tue, 21 Aug 2012 13:37:29 +0200") Message-ID: <87vcgcdoml.fsf@pobox.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Pobox-Relay-ID: 6C87F6A6-EBC7-11E1-9516-11610E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-Spam-Score: -2.1 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) On Tue 21 Aug 2012 13:37, ludo@gnu.org (Ludovic Court=C3=A8s) writes: >> It seems clear that in this case, Guile "should" know how to dispatch >> on the format string just once, outside of the loop, instead of doing >> it in every iteration. > > I think Andy would say: =E2=80=9Cinline cache!=E2=80=9D. :-) :-) There are lots of possibilities here. You could "compile" a format string into a closure, and save it in a hash table. You could compile it to Scheme and then compile that procedure. You could recognize some common degenerate cases. Dunno! In this case I would compile the string into a closure. Seems pretty cheap and it would kill the dispatch overhead. Andy --=20 http://wingolog.org/ From unknown Wed Sep 10 13:55:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12033: closed (Re: bug#12033: format should be faster) Resent-From: nalaginrut Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Thu, 23 Aug 2012 03:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12033 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Andy Wingo Cc: Noah Lavine , Ludovic =?UTF-8?Q?Court=C3=A8s?= , 12033@debbugs.gnu.org Received: via spool by 12033-submit@debbugs.gnu.org id=B12033.134569227510704 (code B ref 12033); Thu, 23 Aug 2012 03:25:02 +0000 Received: (at 12033) by debbugs.gnu.org; 23 Aug 2012 03:24:35 +0000 Received: from localhost ([127.0.0.1]:44129 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T4O25-0002ma-TZ for submit@debbugs.gnu.org; Wed, 22 Aug 2012 23:24:34 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:56852) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T4O23-0002mS-Ui for 12033@debbugs.gnu.org; Wed, 22 Aug 2012 23:24:32 -0400 Received: by wibhm6 with SMTP id hm6so275289wib.15 for <12033@debbugs.gnu.org>; Wed, 22 Aug 2012 20:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :organization:content-type:x-mailer:content-transfer-encoding :mime-version; bh=DcNgNw1fBznlCVM12tr/WmlxPAG1Fv0d+9ia6WLh/E8=; b=EaH6JXvJv1yfY0oa0c3vPbyLtAaauBCNXjOvzW6HxslZ0EFz/nTAN60G1w89KxfVDp jk0LfnWmqBtQMKym1hVrUgcXflPnT6eB6EIxxOHLV4OgNw3nMSFAaZGoeAnJN64g/15w /ONKoLcfl/BX2L9YGGRyuXSmixOx5vTjmIhWccR2DWyAFgu5KQ3+nMfNDSEeS5SFuRCX ggnMLcmyXW/aFt1IzPfOT9RGpmC10uODcUgh9Zr6kHtbSU7iI+rK1KGI5e3wJcWGQi7x vCdh0bxjjBfl8FRoxVO7/OUceMl0o/T1HfRJEfrkr+0GdrpxazQlNaNyMZgCnkU5rJop a0mw== Received: by 10.180.79.229 with SMTP id m5mr220835wix.13.1345692242790; Wed, 22 Aug 2012 20:24:02 -0700 (PDT) Received: from [147.2.147.112] ([61.14.130.226]) by mx.google.com with ESMTPS id dc3sm42496671wib.7.2012.08.22.20.23.59 (version=SSLv3 cipher=OTHER); Wed, 22 Aug 2012 20:24:02 -0700 (PDT) Message-ID: <1345692236.5141.79.camel@Renee-SUSE.suse> From: nalaginrut Date: Thu, 23 Aug 2012 11:23:56 +0800 In-Reply-To: <87vcgcdoml.fsf@pobox.com> References: <878vd9i651.fsf@gnu.org> <1343023866.4060.12.camel@Renee-SUSE.suse> <87boi5gpg0.fsf@gnu.org> <1345517459.5141.62.camel@Renee-SUSE.suse> <87ipccqxvq.fsf@gnu.org> <87vcgcdoml.fsf@pobox.com> Organization: HFG Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3 Content-Transfer-Encoding: 8bit Mime-Version: 1.0 X-Spam-Score: -2.6 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) hey guys! Any conclusion? On Tue, 2012-08-21 at 21:35 +0200, Andy Wingo wrote: > On Tue 21 Aug 2012 13:37, ludo@gnu.org (Ludovic Courtès) writes: > > >> It seems clear that in this case, Guile "should" know how to dispatch > >> on the format string just once, outside of the loop, instead of doing > >> it in every iteration. > > > > I think Andy would say: “inline cache!”. :-) > > :-) > > There are lots of possibilities here. You could "compile" a format > string into a closure, and save it in a hash table. You could compile > it to Scheme and then compile that procedure. You could recognize some > common degenerate cases. > > Dunno! In this case I would compile the string into a closure. Seems > pretty cheap and it would kill the dispatch overhead. > > Andy From unknown Wed Sep 10 13:55:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12033: closed (Re: bug#12033: format should be faster) Resent-From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Thu, 23 Aug 2012 21:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12033 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: nalaginrut Cc: Andy Wingo , Noah Lavine , 12033@debbugs.gnu.org Received: via spool by 12033-submit@debbugs.gnu.org id=B12033.134575894216731 (code B ref 12033); Thu, 23 Aug 2012 21:56:01 +0000 Received: (at 12033) by debbugs.gnu.org; 23 Aug 2012 21:55:42 +0000 Received: from localhost ([127.0.0.1]:45586 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T4fNN-0004Lo-Us for submit@debbugs.gnu.org; Thu, 23 Aug 2012 17:55:42 -0400 Received: from xanadu.aquilenet.fr ([88.191.123.111]:52600) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T4fNL-0004Lf-15 for 12033@debbugs.gnu.org; Thu, 23 Aug 2012 17:55:40 -0400 Received: from localhost (localhost [127.0.0.1]) by xanadu.aquilenet.fr (Postfix) with ESMTP id D32799240; Thu, 23 Aug 2012 23:55:03 +0200 (CEST) Received: from xanadu.aquilenet.fr ([127.0.0.1]) by localhost (xanadu.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QJjq4rQvCO6K; Thu, 23 Aug 2012 23:55:03 +0200 (CEST) Received: from pluto (reverse-83.fdn.fr [80.67.176.83]) by xanadu.aquilenet.fr (Postfix) with ESMTPSA id 3D59B923F; Thu, 23 Aug 2012 23:55:03 +0200 (CEST) From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <878vd9i651.fsf@gnu.org> <1343023866.4060.12.camel@Renee-SUSE.suse> <87boi5gpg0.fsf@gnu.org> <1345517459.5141.62.camel@Renee-SUSE.suse> <87ipccqxvq.fsf@gnu.org> <87vcgcdoml.fsf@pobox.com> <1345692236.5141.79.camel@Renee-SUSE.suse> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 7 Fructidor an 220 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu Date: Thu, 23 Aug 2012 23:55:02 +0200 In-Reply-To: <1345692236.5141.79.camel@Renee-SUSE.suse> (nalaginrut@gmail.com's message of "Thu, 23 Aug 2012 11:23:56 +0800") Message-ID: <87k3wpff49.fsf@gnu.org> User-Agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.2 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.2 (-) Hi, nalaginrut skribis: > hey guys! Any conclusion? I think there=E2=80=99s no simpler answer, so no conclusion. We=E2=80=99d = have to experiment with the various possibilities (=E2=80=98define-inlinable=E2=80= =99 for =E2=80=98format=E2=80=99, a =E2=80=98format*=E2=80=99 macro, or compiler su= pport). Of course, you=E2=80=99re welcome to give it a go and let guile-devel know!= :-) Ludo=E2=80=99.