Lots of concurrent IO.

Marcio Marchini mqm at magma.ca
Thu Aug 16 03:26:51 UTC 2001


> Hmm.  Yes, 50% is being used to poll for input in this extreme case.
> But it *is* the extreme case!  It's a large number of connections, with
> a not-too-fast computer, where you are expecting very few active sockets
> but for those sockets to consume a lot of CPU.
>
> Also, #dataAvailable hasn't been optimized at all.  Currently it is
> making a system call into the kernel (this was on Linux, by the way),
> but probably it could be improved to cache the results if nothing has
> changed about the socket.  In fact, it might be worth revisiting the
> whole VM<->image network interface with a mind to servers -- the current
> setup is really optimized, it seems, for clients that have a single
> socket open and which have nothing to do while waiting for the socket to
> become active.


	Hmmm, I guess this starts to answer my question on using headless Squeak as
web app server :-(

	What we did for Eiffel (see yaesockets,
http://sourceforge.net/projects/yaesockets/ ) was to create a socket
multiplexer class, and you get callbacks when a socket is available for
reads or writes. So, in some sense it is reactive programming, it is all
callback based. You need no Threads, since callbacks will be serialized by
the multiplexer, but you find yourself using state machines because you get
bytes in chunks (you never really issue a blocking read, you react to a
multiplexer callback saying there's N bytes to be read).

	The problem is when you need to multiplex sockets *and* a GUI event queue,
of course. That's why I had the question #2 in my email about Squeak as web
app server.

	Ideally you want to multiplex behind the scenes and use something like
coroutines to provide the illusion, so that you do not have to worry about
state machines. See http://oss.sgi.com/projects/state-threads/ and
http://www.imatix.com/html/smt/

	For headless servers you probably can do the event loop around socket
multiplexing, whereas for GUI apps you can do the event loop around the GUI
event queue. For a TCP/IP server with GUI, you probably want to combine
both, and that's probably why you can get async socket notifications in the
event queue from Windows (not CE, though, AFAIK).


marcio





More information about the Squeak-dev mailing list