From: ludo@gnu.org (Ludovic Courtès)
To: guile-devel@gnu.org
Subject: Re: [BDW-GC] "Inlined" storage; `scm_take_' functions
Date: Wed, 09 Sep 2009 10:03:03 +0200 [thread overview]
Message-ID: <874orcmtoo.fsf@gnu.org> (raw)
In-Reply-To: 874ordf0wq.fsf@arudy.ossau.uklinux.net
Hi Neil!
Neil Jerram <neil@ossau.uklinux.net> 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’.
next prev parent reply other threads:[~2009-09-09 8:03 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 [this message]
2009-09-09 21:38 ` Neil Jerram
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=874orcmtoo.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guile-devel@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).