From: Neil Jerram <neil@ossau.uklinux.net>
To: ludo@gnu.org (Ludovic Courtès)
Cc: guile-devel@gnu.org
Subject: Re: [BDW-GC] "Inlined" storage; `scm_take_' functions
Date: Wed, 09 Sep 2009 22:38:32 +0100 [thread overview]
Message-ID: <877hw77q93.fsf@arudy.ossau.uklinux.net> (raw)
In-Reply-To: <874orcmtoo.fsf@gnu.org> ("Ludovic Courtès"'s message of "Wed\, 09 Sep 2009 10\:03\:03 +0200")
ludo@gnu.org (Ludovic Courtès) writes:
> 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).
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’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.
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’m 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
prev parent reply other threads:[~2009-09-09 21:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-01 0:14 [BDW-GC] "Inlined" storage; `scm_take_' functions Ludovic Courtès
2009-09-01 0:48 ` Mike Gran
2009-09-01 8:20 ` Ludovic Courtès
2009-09-08 23:54 ` Neil Jerram
2009-09-09 8:03 ` Ludovic Courtès
2009-09-09 21:38 ` Neil Jerram [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877hw77q93.fsf@arudy.ossau.uklinux.net \
--to=neil@ossau.uklinux.net \
--cc=guile-devel@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).