[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Single-threading servers and select()
- From: skaller <skaller@...>
- Date: 23 Jan 2005 16:15:52 +1100
On Sun, 2005-01-23 at 15:14, Mike Pall wrote:
> http://www.usenix.org/events/hotos03/tech/vonbehren.html
> "Why Events Are A Bad Idea (for High-concurrency Servers)"
Hehe.. they're at Berkeley. Check out Cappriccio:
http://capriccio.cs.berkeley.edu/
Felix solves the same problem a different way
(using heap frames explicitly and a specialised compiler).
> I think they are basically right and it reassured me that event driven
> systems need to be complemented with good coroutine support. Lua is
> perfect for this.
That depends on the details. Felix was designed from
scratch with control inversion as the core principle.
The other stuff (type system etc) was added afterwards.
Lua was designed as a conventional interpreter first,
coroutines were added afterwards.
Note that all this talk of select/poll/epoll is missing
one point -- web servers, and more generally networking --
is only *one* application where coroutines are useful.
Games and GUI systems are two other systems where
one would like to use a logical thread of control
for each 'object'. So making the OS do event stuff faster
is interesting but only handles a special class of problems.
The more general problem is simply that callbacks,
and many OO languages, suck because the programmer
has to maintain state across yields(), that is,
do everything as a slave. Humans often prefer to
be the master, or at least to cooperate with peers.
That is -- thread style programming is the goal,
whether or not the threads are pre-emptive isn't
really as important as the fact that traditional
block structure/functional styles rely heavily
on control and data being associated via the
concept of a stack.
I should probably modify my brash statement that
callbacks suck .. and change it to say *having
to use callbacks* sucks. In fact I believe
they're quite useful, as a programmer I'd just
like to be able to engineer a choice between
threads and callbacks.
Lua lets you do that to some extent, although
the coroutine interface is a bit lumpy --
ordinary fuctions/closures are still easier to use.
So .. I wouldn't say Lua is 'perfect', that would be
hard to say given the lack of theoretical understanding
of control exchange. but it is certainly interesting
to have a system that can rapidly prototype cooperative
systems!
--
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850,
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net