1998Q3/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: [MUD&#45;Dev] Re: lurker emerges -->
<!--X-From-R13: "F. Oyrknaqre Bbcvry" <cbcvryNfahtuneobe.pbz> -->
<!--X-Date: Sun, 9 Aug 1998 19:19:01 &#45;0700 -->
<!--X-Message-Id: 199808100153.SAA06759#cashew,snugharbor.com.snugharbor.com -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 001e01bdc3ef$7f4573a0$961e5d18#default,rochester.rr.com -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, [MUD-Dev] Re: lurker emerges</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:popiel#snugharbor,com">
</head>
<body background="/backgrounds/paperback.gif" bgcolor="#ffffff"
      text="#000000" link="#0000FF" alink="#FF0000" vlink="#006000">

  <font size="+4" color="#804040">
    <strong><em>MUD-Dev<br>mailing list archive</em></strong>
  </font>
      
<br>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
<br clear=all><hr>
<!--X-Body-Begin-->
<!--X-User-Header-->
<!--X-User-Header-End-->
<!--X-TopPNI-->

Date:&nbsp;
[&nbsp;<a href="msg00602.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00604.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00600.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00602.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00603">Author</A>
&nbsp;|&nbsp;<A HREF="#00603">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00603">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>[MUD-Dev] Re: lurker emerges</H1>
<HR>
<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<UL>
<LI><em>To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
<LI><em>Subject</em>: [MUD-Dev] Re: lurker emerges </LI>
<LI><em>From</em>: "T. Alexander Popiel" &lt;<A HREF="mailto:popiel#snugharbor,com">popiel#snugharbor,com</A>&gt;</LI>
<LI><em>Date</em>: Sun, 09 Aug 1998 18:53:44 -0600</LI>
<LI><em>cc</em>: <A HREF="mailto:popiel#snugharbor,com">popiel#snugharbor,com</A></LI>
<LI><em>Reply-To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
</UL>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<HR>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<PRE>
In message:  &lt;<A HREF="msg00600.html">001e01bdc3ef$7f4573a0$961e5d18#default,rochester.rr.com</A>&gt;
             "James Wilson" &lt;jwilson#rochester,rr.com&gt; writes:
&gt;From: T. Alexander Popiel &lt;popiel#snugharbor,com&gt;
&gt;&gt;
&gt;&gt;You seem to assume that it is impossible for a single thread to keep
&gt;&gt;even one I/O device continuously busy.  Whatever happened to double-
&gt;&gt;buffering and non-blocking I/O?  Has that art actually been lost in
&gt;&gt;the annals of time?
&gt;
&gt;I for one have only a vague idea of what this technique consists of.
&gt;Could you maybe give some details, or a url describing it? Why would
&gt;one need non-blocking i/o if select() tells you which sockets are
&gt;ready for reads and writes? That is, assuming you bound the size of
&gt;your output chunks appropriately, if the socket's ready for i/o shouldn't
&gt;blocking be moot?

Addressing questions in reverse order: no, select() does not make
non-blocking moot, because while it tells you when some amount of
I/O is possible, it does not tell you how much I/O is possible.
It may be that you are now free to read or write only one byte,
and a request to read or write two bytes will cause your program
to block.  There is no way to tell what the appropriate size for
your 'chunks' should be.

Double-buffering is a technique I heard about in conjunction with
old reel-to-reel tape drives, where there was great cost (both in
time and hardware lifespan) to having a pause between two read (or
write) requests, since the tape would have to stop, back up a bit,
and then spin back up to speed before it could service the delayed
second request.  To avoid this delay, a typical read session would:
request a read(#1) of n blocks into buffer 1, request a read(#2) of
n blocks into buffer 2, wait for the read(#1) to complete, process
the data in buffer 1, request a read(#3) of n blocks into buffer 1,
wait for the read(#2) to complete, process the data in buffer 2,
request a read(#4) of n blocks into buffer 2, wait for the read(#3)
to complete, etc...  In this way, there was always a read request
pending on the drive, so it never had to do one of those costly
stops.  (Note that this technique only works if the processing time
for the data is smaller than the I/O time for the data... but it
was usually true then, and with CPUs these days, it's usually true
now, too.)

Unfortunately, double-buffering is not well supported by modern
OSes; it doesn't follow select() semantics at all.  You need
notification when any read request is complete, not just when
unrequested data is available.  POSIX generally doesn't like
this, the closest it comes is the background read/write from
tty signals.  SysV and BSD define SIGPOLL and SIGIO, both of
which are again close, but not quite right.  Everything else
seems to be device-dependant.

&gt;&gt;&gt; Don't forget that non-threading has overhead too: if there is
&gt;&gt;&gt; multiple file descriptors then select'ing and going through
&gt;&gt;&gt; fd_sets can burns CPU time too.
&gt;&gt;
&gt;&gt;While this is true, this overhead is something that a creative
&gt;&gt;programmer can manage and reduce
&gt;
&gt;I am curious as to how one could speed up this process - can you
&gt;avoid doing a search through the set of all active sockets to find
&gt;those that are ready for i/o? Could you split up the fd_sets somehow
&gt;to bound the number that would have to be checked? It seems like
&gt;when one gets to thousands of simultaneous connections this 
&gt;could become a bottleneck.

There was a wonderful thread on this a short while ago, under the
subject line "xxx" (I'm looking this up, will get back to you, the
kanga.nu web server (and hence the archives) seem to be down, the
thread was sometime around 14 May 1998).  Solutions presented were
primarily different flavors of fd_set partitioning, either among
multiple threads or by activity level within one thread.  Being a
miserly sort, I prefer the latter. ;-) It was pointed out that there
is a small unavoidable cost to using select() on high fd numbers,
even if you're only checking one, because select must scan all the
fd numbers from 0 to whatever you set for a max, to find the fds
that you're interested in.  This unavoidable cost is fairly small
in comparison to the cost of actually checking a large number of fds...

- Alex


</PRE>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<!--X-Follow-Ups-End-->
<!--X-References-->
<UL><LI><STRONG>References</STRONG>:
<UL>
<LI><STRONG><A NAME="00600" HREF="msg00600.html">[MUD-Dev] Re: lurker emerges</A></STRONG>
<UL><LI><EM>From:</EM> "James Wilson" &lt;jwilson#rochester,rr.com&gt;</LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00602.html">[MUD-Dev] Re: lurker emerges</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00604.html">[MUD-Dev] Re: ADMIN: Advertising on MUD-Dev</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00600.html">[MUD-Dev] Re: lurker emerges</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00602.html">[MUD-Dev] Re: lurker emerges</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00603"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00603"><STRONG>Thread</STRONG></A></LI>
</UL>
</LI>
</UL>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
<ul><li>Thread context:
<BLOCKQUOTE><UL>
<LI><STRONG>[MUD-Dev] Re: lurker emerges</STRONG>, <EM>(continued)</EM>
<ul compact>
<ul compact>
<ul compact>
<ul compact>
<ul compact>
<ul compact>
<ul compact>
<ul compact>
<ul compact>
<LI><strong><A NAME="00656" HREF="msg00656.html">[MUD-Dev] Re: lurker emerges</A></strong>, 
Petri Virkkula <a href="mailto:pvirkkul#iki,fi">pvirkkul#iki,fi</a>, Tue 11 Aug 1998, 07:53 GMT
</LI>
</ul>
<LI><strong><A NAME="00654" HREF="msg00654.html">[MUD-Dev] Re: lurker emerges</A></strong>, 
Vadim Tkachenko <a href="mailto:vt#freehold,crocodile.org">vt#freehold,crocodile.org</a>, Tue 11 Aug 1998, 06:48 GMT
</LI>
</ul>
</ul>
</ul>
</ul>
</ul>
<LI><strong><A NAME="00615" HREF="msg00615.html">[MUD-Dev] Re: lurker emerges</A></strong>, 
Petri Virkkula <a href="mailto:pvirkkul#iki,fi">pvirkkul#iki,fi</a>, Mon 10 Aug 1998, 05:57 GMT
</LI>
</ul>
</ul>
<LI><strong><A NAME="00600" HREF="msg00600.html">[MUD-Dev] Re: lurker emerges</A></strong>, 
James Wilson <a href="mailto:jwilson#rochester,rr.com">jwilson#rochester,rr.com</a>, Sun 09 Aug 1998, 23:54 GMT
<UL>
<LI><strong><A NAME="00603" HREF="msg00603.html">[MUD-Dev] Re: lurker emerges</A></strong>, 
T. Alexander Popiel <a href="mailto:popiel#snugharbor,com">popiel#snugharbor,com</a>, Mon 10 Aug 1998, 02:19 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00602" HREF="msg00602.html">[MUD-Dev] Re: lurker emerges</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Mon 10 Aug 1998, 02:18 GMT
</LI>
<LI><strong><A NAME="00612" HREF="msg00612.html">[MUD-Dev] Re: lurker emerges</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Mon 10 Aug 1998, 05:28 GMT
<UL>
<LI><strong><A NAME="00614" HREF="msg00614.html">[MUD-Dev] Re: lurker emerges</A></strong>, 
Vadim Tkachenko <a href="mailto:vt#freehold,crocodile.org">vt#freehold,crocodile.org</a>, Mon 10 Aug 1998, 05:57 GMT
</LI>
<LI><strong><A NAME="01055" HREF="msg01055.html">[MUD-Dev] Re: lurker emerges</A></strong>, 
J C Lawrence <a href="mailto:claw#under,engr.sgi.com">claw#under,engr.sgi.com</a>, Thu 17 Sep 1998, 00:57 GMT
</LI>
</UL>
</LI>
</ul>
</LI>
</UL></BLOCKQUOTE>

</ul>
<hr>
<center>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
</center>
<hr>
</body>
</html>