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: Mark H Weaver
Subject: Re: Making custom binary input ports unbuffered
Date: Wed, 15 Jan 2014 00:43:05 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Hi Ludovic,

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?

I think it's important that everything that currently works keeps on
working, even if less efficiently.

> 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.

Also, I think we should make R6RS custom binary _output_ ports
unbuffered by default as well, and we should have a way to enable
buffering on them.

Thanks for looking into this!

      Mark



reply via email to

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