From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: thoughts on ports Date: Thu, 17 Jan 2013 15:40:33 +0100 Message-ID: <87hamfdg9q.fsf@pobox.com> References: <87zkam7z5n.fsf@pobox.com> <87aa2jqlst.fsf@gnu.org> 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 1358433646 7934 80.91.229.3 (17 Jan 2013 14:40:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 17 Jan 2013 14:40:46 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Jan 17 15:41:04 2013 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 1TvqeL-0007T4-H0 for guile-devel@m.gmane.org; Thu, 17 Jan 2013 15:41:01 +0100 Original-Received: from localhost ([::1]:40940 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tvqe5-0001W3-0g for guile-devel@m.gmane.org; Thu, 17 Jan 2013 09:40:45 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:43378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tvqdz-0001Ud-Uy for guile-devel@gnu.org; Thu, 17 Jan 2013 09:40:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tvqdy-0003Qc-7Y for guile-devel@gnu.org; Thu, 17 Jan 2013 09:40:39 -0500 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:60655 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tvqdy-0003QW-2U; Thu, 17 Jan 2013 09:40:38 -0500 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id BC934A202; Thu, 17 Jan 2013 09:40:36 -0500 (EST) 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=+1UVYpO7+hjB yKNFRfCKvADsB9A=; b=fWda7cReFSeiZn3fI9fga1kfZSuif0qCmQO8qq+HlRGE 4IUgvoRSq0LHo/FVusodrzkx1QnAkrIQkcsf7pt831aEVrjZnjjS/3XLMK6hrBH6 LTyHiOlFOvguL3m8oZDbpn+xCCSWKU7ZqsKc8zx/LWlrmFg05NTSdNflaqAgT8w= 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=DEDjNo lC2uXSOVUoFdICBvmhT4J8rXcT8KTFoeaoxHtOPHG4maNCV9+1P3mhsh/prT2lib l6zTk4ltMPKSFxFQZSboQApJPctz1h8tBSOTkg6Ku0OaSuWUhbU7zYbG7lWOvx+Q +7VFPw4EZzRtFVAor+Ji88w/US8c1axjTuEMk= Original-Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id B5D3AA201; Thu, 17 Jan 2013 09:40:36 -0500 (EST) Original-Received: from badger (unknown [88.160.190.192]) (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 206E9A200; Thu, 17 Jan 2013 09:40:36 -0500 (EST) In-Reply-To: <87aa2jqlst.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Wed, 11 Apr 2012 00:11:46 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) X-Pobox-Relay-ID: DAE9300E-60B3-11E2-9865-0A4F0E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 208.72.237.25 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:15467 Archived-At: Hi, Again, picking up old things: On Wed 11 Apr 2012 00:11, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Andy Wingo skribis: > >> Obviously we need ports implemented in C because of bootstrapping >> concerns. But can we give Scheme access to buffering and the underlying >> fill (read) / drain (write) / wait (select) operations? >> >> So, the idea: refactor the port buffers (read, write, putback) to be >> Scheme bytevectors, and internally store offsets instead of pointers. >> Give access to some internal port primitives to a new (ice-9 ports) >> module. >> >> I think we can manage to make (ice-9 ports) operate in both binary and >> textual modes without a problem, just as we do with cports. We'll have >> to expose some iconv primitives to (ice-9 ports), but that's just as >> well. (Perhaps we should supply an (ice-9 iconv) module ?) > > I like the idea (more Scheme!). However, it=E2=80=99s not clear to me wh= at the > performance impact would be with Guile=E2=80=99s current state. > > For instance, while =E2=80=98read=E2=80=99 remains in C, it can only suff= er from such a > change. Conversely, things like =E2=80=98get-u8=E2=80=99 and =E2=80=98ge= t-bytevector-n!=E2=80=99 may be > faster. OTOH, the equivalent of =E2=80=98get_utf8_codepoint=E2=80=99 is = likely to be > much slower. And we still need to call out to C for =E2=80=98iconv=E2=80= =99 and > libunistring. As a thought experiment, I don't see why things should have to slow down. Master has `scm_c_take_gc_bytevector', which can be used to wrap the existing scm_t_port::write_buf, ::read_buf, and ::putback_buf members. At the cost of three allocations per port and three words per allocation (bytevector tag, length, and pointer), we could give access to these internal buffers to Scheme without affecting the C code at all. We could go farther and allocate the buffers as bytevectors directly, which would entail an additional indirection for C to get at the length and data, but the length and data would all be contiguous anyway so in practice I don't see it being too bad. I'll see what I can do in a branch. Andy --=20 http://wingolog.org/