From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.devel Subject: Re: [BDW-GC] "Inlined" storage; `scm_take_' functions Date: Wed, 09 Sep 2009 22:38:32 +0100 Message-ID: <877hw77q93.fsf@arudy.ossau.uklinux.net> References: <874ornldw0.fsf@gnu.org> <874ordf0wq.fsf@arudy.ossau.uklinux.net> <874orcmtoo.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1252532352 21991 80.91.229.12 (9 Sep 2009 21:39:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 9 Sep 2009 21:39:12 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Sep 09 23:39:05 2009 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MlUsa-0000sK-92 for guile-devel@m.gmane.org; Wed, 09 Sep 2009 23:39:04 +0200 Original-Received: from localhost ([127.0.0.1]:45384 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlUsZ-0001IW-FO for guile-devel@m.gmane.org; Wed, 09 Sep 2009 17:39:03 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlUsW-0001H0-PZ for guile-devel@gnu.org; Wed, 09 Sep 2009 17:39:00 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlUsS-0001Go-6p for guile-devel@gnu.org; Wed, 09 Sep 2009 17:39:00 -0400 Original-Received: from [199.232.76.173] (port=57991 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlUsS-0001Gl-41 for guile-devel@gnu.org; Wed, 09 Sep 2009 17:38:56 -0400 Original-Received: from mail3.uklinux.net ([80.84.72.33]:49005) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MlUsN-0004A5-Ga; Wed, 09 Sep 2009 17:38:51 -0400 Original-Received: from arudy (host86-152-99-133.range86-152.btcentralplus.com [86.152.99.133]) by mail3.uklinux.net (Postfix) with ESMTP id 74FC01F6731; Wed, 9 Sep 2009 22:38:48 +0100 (BST) Original-Received: from arudy.ossau.uklinux.net (arudy [127.0.0.1]) by arudy (Postfix) with ESMTP id E3D9138021; Wed, 9 Sep 2009 22:38:32 +0100 (BST) In-Reply-To: <874orcmtoo.fsf@gnu.org> ("Ludovic =?iso-8859-1?Q?Court=E8s?= =?iso-8859-1?Q?=22's?= message of "Wed\, 09 Sep 2009 10\:03\:03 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:9295 Archived-At: ludo@gnu.org (Ludovic Court=C3=A8s) writes: > It=E2=80=99s not such a shame IMO because: > > * You have to allocate anyway, to store the (double) cell, and > allocating the whole thing may be just as costly as allocating the > cell, at least for small stringbufs/bytevectors. > > * For stringbufs, the user-provided buffer can be reused only if it=E2= =80=99s > either Latin-1 or UCS-4, anyway. > > * Removing the indirection and using only GC-managed memory is > beneficial for Scheme code (which doesn=E2=80=99t use =E2=80=98scm_ta= ke=E2=80=99). > > * Reusing the malloc(3)-allocated buffer means that we have to > register a finalizer to later free(3) that buffer (see, e.g., commit > d7e7a02a6251c8ed4f76933d9d30baeee3f599c0), which is costly (see, e.g., > http://www.hpl.hp.com/personal/Hans_Boehm/popl03/web/html/slide_7.htm= l). All good points. > That said... > >> Did you consider the option of >> >> - always having an indirection from the stringbuf/bytevector object to >> the underlying data > > ... this may be valuable (Andy pointed it out as well), at least for > bytevectors. The indirection is a requirement for Andy=E2=80=99s > SRFI-4-on-bytevector patch set, so that =E2=80=98scm_take_u8vector=C2=A0(= )=E2=80=99 can still > be supported; it=E2=80=99s also required if we want to provide mmap(3) bi= ndings, > for instance, that return a bytevector. OK, cool. It was actually large bytevectors that I was mostly thinking about, and IIUC it sounds quite likely that we will end up keeping meaningful scm_take_... functions there. > For stringbufs, though, I=E2=80=99m happy if we can leave the code as it = is. Yes, fine. For stringbufs reallocating feels less painful, especially given the encoding restriction. Thanks! Neil