From: Mark H Weaver <mhw@netris.org>
To: Nala Ginrut <nalaginrut@gmail.com>
Cc: guile-devel@gnu.org
Subject: Re: [PATCH] Add current-suspendable-io-status parameter
Date: Wed, 15 May 2019 20:58:01 -0400 [thread overview]
Message-ID: <87zhnni5aj.fsf@netris.org> (raw)
In-Reply-To: <CAPjoZoebyCx1e7xwZEOqqvYonnmNiUcHdb=wiC2RgVq5PEHjOA@mail.gmail.com> (Nala Ginrut's message of "Wed, 15 May 2019 17:31:31 +0800")
Hi Nala,
Nala Ginrut <nalaginrut@gmail.com> writes:
> I think your approach works for the cases which use put-bytevector* directly.
> Are you assuming the server-core only handles suspendable-port with
> put-bytevector in http-read or http-write?
> If so, then your approach is not enough.
If you're not using 'put-bytevector', then the 'start' and 'count'
variables in {read,write}-bytes will not relate to your buffer, and
therefore will not be meaningful.
For example, suppose you use 'put-string' to write 20 thousand
characters to a socket. While that operation is pending, presumably you
would like information on how many of those characters have been
written, i.e. you want a number in the range 0 to 20000. Am I right?
'start' and 'count' from {read,write}-bytes will not tell you how much
of that string has been written. What will happen is this: the initial
characters of the string will be converted into the port encoding, as
much as will fit in the port "auxiliary write buffer", which is 256
bytes long. Those ~256 bytes will be written using 'write-bytes', so
'start' will typically be 0 and 'count' will be a number <= 256. That
will happen repeatedly until the entire string has been written.
Do you see now why your approach will not work?
In general, the I/O operations visible to the user may be broken up into
smaller operations within Guile. If we are to provide I/O progress
information, we must provide information that relates to the operations
that the user knows about. The fundamental problem with your proposed
patch is that it does not do that.
> That is to say, every I/O operation should have the ability to return
> the current I/O status for the scheduler.
It's a reasonable wish. You'd like to provide progress information for
all I/O operations in a single stroke, without having to write something
like 'put-bytevector*' for each I/O primitive.
It would be nice if 'start' and 'count' from {read,write}-bytes were
able to provide universally-applicable progress information for any I/O
operation. I've explained above why it doesn't.
I thought a bit about what a universally-applicable progress indicator
would look like, and I can't think of a good way to do it. It might be
better to start by thinking about some specific examples of other I/O
operations.
I've already given the example of writing a string, but let's think a
bit more about that case. For textual I/O, arguably the progress
information should be given as a number of *characters* written. We
could also in theory provide the number of bytes written, but we can't
say how many bytes remain to be written, or what the total number of
bytes will be. We can only say how many *characters* remain to be
written.
What about when we write something more structured, such as writing a
large S-expression using 'write', or serializing XML from SXML. In
those cases, it's even more obvious that we have no idea how many bytes,
nor how many characters will be written, until we're finished. Both of
these operations result in a large number of small write operations, and
clearly, status information for each of those small write operations is
not useful.
In your opinion, how should I/O progress information be represented in
these cases?
Can you see now why your approach doesn't work for most I/O operations?
Regards,
Mark
next prev parent reply other threads:[~2019-05-16 0:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-13 10:54 [PATCH] Add current-suspendable-io-status parameter Nala Ginrut
2019-05-13 10:56 ` Nala Ginrut
2019-05-13 20:54 ` Mark H Weaver
2019-05-13 23:00 ` Mark H Weaver
2019-05-14 4:22 ` Nala Ginrut
2019-05-14 20:22 ` Mark H Weaver
2019-05-15 9:31 ` Nala Ginrut
2019-05-16 0:58 ` Mark H Weaver [this message]
2019-05-17 11:07 ` Nala Ginrut
2019-05-18 23:06 ` Mark H Weaver
2019-05-15 10:09 ` tomas
2019-05-15 11:25 ` Chris Vine
2019-05-15 12:08 ` tomas
2019-05-15 11:25 ` Nala Ginrut
2019-05-15 12:10 ` tomas
2019-05-15 12:26 ` Nala Ginrut
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=87zhnni5aj.fsf@netris.org \
--to=mhw@netris.org \
--cc=guile-devel@gnu.org \
--cc=nalaginrut@gmail.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).