unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: ludovic.courtes@laas.fr (Ludovic Courtès)
To: Neil Jerram <neil@ossau.uklinux.net>
Cc: Guile-Devel <guile-devel@gnu.org>
Subject: Re: Unbuffered socket I/O
Date: Thu, 01 Mar 2007 10:10:19 +0100	[thread overview]
Message-ID: <87wt21cosk.fsf@laas.fr> (raw)
In-Reply-To: <87d53u7z6k.fsf@zip.com.au> (Kevin Ryde's message of "Thu, 01 Mar 2007 08:24:51 +1100")

Hi,

Kevin Ryde <user42@zip.com.au> writes:

> ludovic.courtes@laas.fr (Ludovic Courtès) writes:
>>
>>            (uniform-vector-read! vec port)))
>
> Slackness in the implementation of that function.  It knows a size to
> read and should come out as a read() system call of that size.  Yet it
> always goes through the port buffer.

I believe it's a feature, not some "slackness".  ;-)

The function is meant to read from _any_ kind of input port.  Thus, it
can definitely not use the `read ()' system call to that end.  Instead,
it rightfully uses one of the two public functions available to read
from an arbitrary port: `scm_getc ()' and `scm_c_read ()'.

> read-string!/partial is much better in that respect.  Maybe that func
> should be loosened up to work on non-fports too, that could be nice.
>
> It's a bit of a failing of the ptab port functions that there's no
> "read N bytes", but that needn't prevent uniform-vector-read! doing
> the right thing on fports.

There's `scm_c_read ()' for "read N bytes", but it translates into N
calls to `scm_getc ()'.  If the port is unbuffered, then each invocation
of `scm_getc ()' translates in one `scm_fill_input ()' call, which in
turn translates in one `select ()' and one `read ()' of size 1.  I think
_this_ is the issue, not the fact that `uniform-vector-read!' can read
from any kind of port.

IMO it feels wrong to dismiss the port abstraction (e.g., by testing for
fports and using fport-specific I/O methods) just to work around this
performance problem.

> Could also think if those calls should then cope with O_NONBLOCK
> too, by sleeping in select() if finding there's nothing to read yet.
> On a single read call I would say let it throw an error, but if the
> aim is to block until the requested size then it's easy enough to
> cope.

I noticed that `fport_fill_input ()' would raise an error when reading
from a non-blocking file descriptor where input is not available (i.e.,
when `read ()' returns -1 with ERRNO == EWOULDBLOCK).  Thus it must be
inconvenient (at best) to use the port I/O functions on a port whose
underlying FD is in non-blocking mode.  I don't know what would need to
be done to fix this.

Thanks,
Ludovic.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


  reply	other threads:[~2007-03-01  9:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-23 17:09 Unbuffered socket I/O Ludovic Courtès
2007-02-23 22:36 ` Neil Jerram
2007-02-25 22:57 ` Kevin Ryde
2007-02-26 14:07   ` Ludovic Courtès
2007-02-26 20:32     ` Neil Jerram
2007-02-26 23:35       ` Kevin Ryde
2007-02-27  9:11       ` Ludovic Courtès
2007-02-28 21:24         ` Kevin Ryde
2007-03-01  9:10           ` Ludovic Courtès [this message]
2007-03-04 23:48             ` Kevin Ryde
2007-03-07  0:20             ` Kevin Ryde
2007-03-07  0:30             ` Kevin Ryde
2007-03-07  4:45               ` Kevin Ryde
2007-03-07  9:40               ` Ludovic Courtès
2007-02-26 23:27     ` Kevin Ryde
2007-02-28  9:47       ` Ludovic Courtès
2007-02-28 20:59         ` Kevin Ryde
2007-03-01 10:44           ` Ludovic Courtès
2007-03-05 23:15             ` Kevin Ryde
2007-08-07 16:01               ` Ludovic Courtès
2007-05-13 17:13       ` `scm_std_select ()' call in `fport_wait_for_input ()' 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=87wt21cosk.fsf@laas.fr \
    --to=ludovic.courtes@laas.fr \
    --cc=guile-devel@gnu.org \
    --cc=neil@ossau.uklinux.net \
    /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).