From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: [BDW-GC] "Inlined" storage; `scm_take_' functions Date: Wed, 09 Sep 2009 10:03:03 +0200 Message-ID: <874orcmtoo.fsf@gnu.org> References: <874ornldw0.fsf@gnu.org> <874ordf0wq.fsf@arudy.ossau.uklinux.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1252483477 8412 80.91.229.12 (9 Sep 2009 08:04:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 9 Sep 2009 08:04:37 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Sep 09 10:04:30 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 1MlIAH-0000xd-QQ for guile-devel@m.gmane.org; Wed, 09 Sep 2009 10:04:30 +0200 Original-Received: from localhost ([127.0.0.1]:36212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlIAG-0008QS-SJ for guile-devel@m.gmane.org; Wed, 09 Sep 2009 04:04:28 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlI9W-00082M-IO for guile-devel@gnu.org; Wed, 09 Sep 2009 04:03:42 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlI9R-0007x3-D1 for guile-devel@gnu.org; Wed, 09 Sep 2009 04:03:41 -0400 Original-Received: from [199.232.76.173] (port=60870 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlI9R-0007ws-7o for guile-devel@gnu.org; Wed, 09 Sep 2009 04:03:37 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]:10386) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MlI9Q-0000zH-IK for guile-devel@gnu.org; Wed, 09 Sep 2009 04:03:36 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MlI9P-0002hJ-QI for guile-devel@gnu.org; Wed, 09 Sep 2009 04:03:36 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.50) id 1MlI9H-0000hn-SW for guile-devel@gnu.org; Wed, 09 Sep 2009 10:03:27 +0200 Original-Received: from laptop-147-210-128-170.labri.fr ([147.210.128.170]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 09 Sep 2009 10:03:27 +0200 Original-Received: from ludo by laptop-147-210-128-170.labri.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 09 Sep 2009 10:03:27 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 52 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: laptop-147-210-128-170.labri.fr X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 23 Fructidor an 217 de la =?iso-8859-1?Q?R=E9volutio?= =?iso-8859-1?Q?n?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 821D 815D 902A 7EAB 5CEE D120 7FBA 3D4F EB1F 5364 X-OS: x86_64-unknown-linux-gnu User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:TKfUi8nKGBN+KBAnhhqd/1daOAo= X-Detected-Operating-System: by mx20.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:9288 Archived-At: Hi Neil! Neil Jerram writes: > ludo@gnu.org (Ludovic Courtès) writes: >> Stringbufs and bytevectors are now always "inlined" in the BDW-GC >> branch [0, 1], which means that there's no cell->buffer indirection, >> which greatly simplifies code (it also takes less room and may slightly >> improve performance). >> >> The `scm_take_' functions for strings/symbols/bytevectors are now >> essentially aliases to the corresponding `scm_from_' because we cannot >> advantageously reuse the provided storage. > > That seems a bit of a shame. (i.e. that we can't advantageously keep > the caller's string or vector data) It’s 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’s either Latin-1 or UCS-4, anyway. * Removing the indirection and using only GC-managed memory is beneficial for Scheme code (which doesn’t use ‘scm_take’). * 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.html). 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’s SRFI-4-on-bytevector patch set, so that ‘scm_take_u8vector ()’ can still be supported; it’s also required if we want to provide mmap(3) bindings, for instance, that return a bytevector. For stringbufs, though, I’m happy if we can leave the code as it is. Thanks, Ludo’.