guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Making custom binary input ports unbuffered


From: Ludovic Courtès
Subject: Re: Making custom binary input ports unbuffered
Date: Wed, 15 Jan 2014 12:48:11 +0100
User-agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux)

Mark H Weaver <address@hidden> skribis:

> address@hidden (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’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]