[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: call/cc



Although I agree that this is pretty off topic, as a systems kid, I'd like
to put my .02 in on the threading vs. continuations discussion. The
threading vs. event-driven servers debate is something that is hammered home
in MIT systems courses. The conclusion fed to the students is that events
(read: continuation invocations) are *the* way to program high-performance
servers. The main points in favor of event-driven programming are
well-conditionedness (allocating threads for connections degrades *very*
poorly under load, under the weight of context switching) and better
application control of scheduling.

As far as I know, the Flash web server [1] was the first work to really
quantitatively drive home the benefits of events. I think SEDA [2]
(mentioned by Dan) is great reading for the current state of the art. It
shows how managing queues of events between stages in your server can
provide great performance under extreme load by allowing fine-grained
scheduling/load shedding decisions in an application-dependent way. (It also
shows how threads and events can coexist happily :) ). Either the Flash or
SEDA paper would offer a good introduction to why continuations outperform
threads under load.

David Mazières wrote a pretty elaborate C++ library for writing servers with
CPS, called libasync. It was part of his dissertation on the Self-certifying
File System, and is available as part of the distribution [3]. libasync is
used as the basis for all the labs in MIT course 6.824, "Distributed
Computer Systems." It turns out to be an intuitive way for students to
implement servers, once they get the hang of it.

,steven.

[1] Flash: An efficient and portable Web server:
http://www.cs.rice.edu/~druschel/usenix99flash.ps.gz
[2] SEDA website: http://www.cs.berkeley.edu/~mdw/proj/seda/
[3] SFS: http://www.fs.net