From: ludo@gnu.org (Ludovic Courtès)
To: Mark H Weaver <mhw@netris.org>
Cc: Andy Wingo <wingo@pobox.com>, guile-devel <guile-devel@gnu.org>
Subject: Re: Making custom binary input ports unbuffered
Date: Wed, 15 Jan 2014 12:48:11 +0100 [thread overview]
Message-ID: <87a9exwjno.fsf@gnu.org> (raw)
In-Reply-To: <87k3e1vlzq.fsf@netris.org> (Mark H. Weaver's message of "Wed, 15 Jan 2014 00:43:05 -0500")
Mark H Weaver <mhw@netris.org> skribis:
> ludo@gnu.org (Ludovic Courtès) writes:
>
>> As discussed on IRC, our R6 custom binary input ports (CBIPs) are
>> currently buffered. The buffer is hard-coded and setvbuf doesn’t work
>> on non-file ports.
>
> [...]
>
>> The patch below makes CBIPs unbuffered (see the tests for the properties
>> it gives.) It works thanks to the optimization in ‘scm_c_read’ for
>> unbuffered binary ports.
>
> When you say "It works thanks to the optimization in 'scm_c_read'", do
> you mean that something will be broken if another method of reading is
> used?
No; I mean that without that optimization ‘read!’ would be called for
one byte at a time.
>> This is going to be a performance hit for applications that read things
>> byte by byte, *or* via textual procedures (‘scm_getc’, ‘get-string’,
>> etc.) But the assumption is that people rather use ‘get-bytevector-n’
>> (or similar) to get a chunk of data.
>>
>> However! There are places in (web ...) where CBIPs are used for mixed
>> binary/textual input. When that happens, all the accesses end up being
>> unbuffered, which really sucks.
>>
>> So, what do we do? :-)
>
> While I agree that CBIPs should be unbuffered by default, I think it's
> important to have a way to enable buffering, even if it's not portable.
Yeah, that’s probably the right thing to do.
I’m a bit afraid of the consequences of allowing non-file ports for
‘setvbuf’, but I’ll experiment and see if it causes any problems.
Thanks for your feedback!
Ludo’.
next prev parent reply other threads:[~2014-01-15 11:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-14 23:00 Making custom binary input ports unbuffered Ludovic Courtès
2014-01-15 5:43 ` Mark H Weaver
2014-01-15 11:48 ` Ludovic Courtès [this message]
2014-01-15 22:51 ` Ludovic Courtès
2014-01-16 0:15 ` Mark H Weaver
2014-01-16 23:00 ` Ludovic Courtès
2014-01-18 21:57 ` Ludovic Courtès
2014-01-21 7:41 ` Mark H Weaver
2014-01-21 10:50 ` Ludovic Courtès
2014-01-21 14:46 ` Mark H Weaver
2014-01-21 17:37 ` Ludovic Courtès
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=87a9exwjno.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guile-devel@gnu.org \
--cc=mhw@netris.org \
--cc=wingo@pobox.com \
/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).