From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: wip-ports-refactor Date: Sun, 17 Apr 2016 12:44:59 +0200 Message-ID: <87a8ksecpg.fsf@gnu.org> References: <87twjempnf.fsf@pobox.com> <87zisw9tju.fsf@gnu.org> <8760vgmxfy.fsf@pobox.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1460889925 16634 80.91.229.3 (17 Apr 2016 10:45:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 17 Apr 2016 10:45:25 +0000 (UTC) Cc: guile-devel To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Apr 17 12:45:15 2016 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1arkCZ-0007yl-2y for guile-devel@m.gmane.org; Sun, 17 Apr 2016 12:45:15 +0200 Original-Received: from localhost ([::1]:44151 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1arkCY-0005yd-0L for guile-devel@m.gmane.org; Sun, 17 Apr 2016 06:45:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1arkCQ-0005uo-NL for guile-devel@gnu.org; Sun, 17 Apr 2016 06:45:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1arkCN-0004Pw-HL for guile-devel@gnu.org; Sun, 17 Apr 2016 06:45:06 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:45339) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1arkCN-0004Ps-E8; Sun, 17 Apr 2016 06:45:03 -0400 Original-Received: from reverse-83.fdn.fr ([80.67.176.83]:40882 helo=pluto) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1arkCM-0000lB-8I; Sun, 17 Apr 2016 06:45:02 -0400 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 29 Germinal an 224 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x3D9AEBB5 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-unknown-linux-gnu In-Reply-To: <8760vgmxfy.fsf@pobox.com> (Andy Wingo's message of "Sun, 17 Apr 2016 10:49:53 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:18290 Archived-At: Andy Wingo skribis: > I want to test four things. > > ;; 1. How long a loop up to 10 million takes (baseline measurement). > (let ((port (open-input-string "s"))) (do-times #e1e7 1)) > > ;; 2. A call to a simple Scheme function. > (define (foo port) 42) > (let ((port (open-input-string "s"))) (do-times #e1e7 (foo port))) > > ;; 3. A call to a port subr. > (let ((port (open-input-string "s"))) (do-times #e1e7 (port-line port= ))) > > ;; 4. A call to a port subr that touches the buffer. > (let ((port (open-input-string "s"))) (do-times #e1e7 (peek-char port= ))) > > The results: > > | baseline | foo | port-line | peek-char > ------------------+----------+--------+-----------+---------- > guile 2.0 | 0.269s | 0.845s | 1.067s | 1.280s > guile master | 0.058s | 0.224s | 0.225s | 0.433s > wip-port-refactor | 0.058s | 0.220s | 0.226s | 0.375s Oh, nice! (By =E2=80=9Cprohibitively slow=E2=80=9D I was referring to 2.0.) For =E2=80=98peek-char=E2=80=99, isn=E2=80=99t there also the fact that str= ing ports in 2.2 are UTF-8 by default, so we get the fast path, whereas in 2.0 there =E2=80=98%default-port-encoding=E2=80=99, which could be something else lea= ding to the slow path? Would be nice to check if doing: (with-fluids ((%default-port-encoding "UTF-8")) (open-input-string "s")) makes a difference in the 2.0 measurements. I hadn=E2=80=99t realized that subr calls had become this cheaper in 2.2, t= hat=E2=80=99s awesome. > Anyway. I think that given the huge performance window opened up to us > by the 2.0->2.2 switch, we should consider speed considerations as > important but not primary -- when given a choice between speed and > maintainability, or speed and the ability to suspend a port, we > shouldn't choose speed. Agreed. > That said, the real way to make port operations fast is (1) to buffer > the port, and (2) to operate on the buffer directly instead of fetching > data octet-by-octet. Exposing the port buffer to Scheme allows this > kind of punch-through optimization to be implemented where needed. In fact my comment about speed was because I was expecting the port-refactor work to improve performance for things like =E2=80=98read-cha= r=E2=80=99, which seems to be the case already. Thank you! Ludo=E2=80=99.