Why Events Are A “Bad” Idea
(for high-concurrency servers)
Paper by: Behren, Condit and Brewer,
Presented by: Rania Elnaggar
Background: What are we talking about?
“Thread” of discussion – Related work
Define the two models
Countering criticism to threads
Strengths of threaded model
Implementation in Knot
Conclusion & future directions
Rania Elnaggar 2
Rania Elnaggar 3
“Thread” of discussion
"Why Threads Are A Bad Idea (for most purposes)" by John Ousterhout,
Talk Slides, Sun Microsystems Laboratories. September 1995.
"SEDA: An Architecture for Well-Conditioned, Scalable Internet
Services" Services" by Welsh, Culler, and Brewer, In Proceedings of the
Eighteenth Symposium on Operating Systems Principles (SOSP-18), Banff,
Canada, October, 2001.
"On the Duality of Operating System Structures" by Lauer and Needham,
in Proc. Second International Symposium on Operating Systems Principles, Oct
1978. Reprinted in SIGOPS Operating Systems Review, 13,2, Pages 3-19, April
"Why Events Are A Bad Idea (for high-concurrency servers)" by Rob von
Behren, Jeremy Condit and Eric Brewer, in proceedings HotOS IX, Kauai,
Hawaii, May 2003.
Rania Elnaggar 4
Which side is better?
Is it a dichotomy?
Camp Events Camp Threads
Rania Elnaggar 5
Small number of static processes
Pre-defined, static communication mechanisms
Address space is divided
Synchronization and cooperation through
message passing, therefore, known as message-
No “mutual” sharing of data
Blocked I/O is complex to handle. Stack ripping.
Rania Elnaggar 6
Scheduler Handler 2
The Pseudo-concurrent model
Rania Elnaggar 7
Large number of dynamic light-weight processes
Classically procedure-oriented through fork and
Synchronization via shared data and interlocking.
System resources encoded as global data
structures and shared via locks
Blocked I/O is a blocked thread. State saved in
Rania Elnaggar 8
1 2 3 n
Shared resources & address space
The Quasi-concurrent model
Rania Elnaggar 9
Beyond the flashy titles!
What it says: Why threads are a “bad” idea.
What it means: Artificial concurrency is bad
when not justified by need.
What it says: Why events are a “bad” idea.
What it means: Events are not concurrent by
definition and thus unsuitable for truly
Rania Elnaggar 10
Apples and Oranges?
Same LABEL, different FORMS
Decaf Diet Light Lemon Forte
Super Super Super Super Super
Drink Drink Drink Drink Drink
Rania Elnaggar 11
Rania Elnaggar 12
Threads exhibit poor
Artifact of poor threading implementation.
Processes that are O(n) should be eliminated
Did not address context switching overhead
due to preemption!
Rania Elnaggar 13
Threads have restrictive
Threads lend themselves to “linear” control
If the control flow is complex, it will be error-
prone and difficult to implement.
Call/return, parallel calls and pipelines are
easily implemented with threads
Dynamic fan-in and fan-out is less graceful
here but not used by highly concurrent
Rania Elnaggar 14
mechanisms are heavyweight
“Cooperative scheduling” is free
synchronization for events
Not a property of events but rather of the
Did not counter the argument!
Need to introduce lighter-weight context
Rania Elnaggar 15
Thread stacks are poorly fitted
for live state mgmt
Waste address space vs. risking stack
Introduce dynamic stack growth
Automatic stack management has a lot of
room for waste.
It shows that those shortcomings can be
overturned not that they don’t exist!
Rania Elnaggar 16
Threads prevent optimal
Optimized scheduling decision can be easily
made for event-driven systems
Ex: shortest-completion time.
Better scheduling for “locality” by running
same-kind events in a row.
Threads can be “scheduled” cooperatively to
reap the same benefits.
Rania Elnaggar 17
Rania Elnaggar 18
Easier to understand in threads
Stack ripping in events and difficulty matching
calls and returns.
Exception handling and state lifetime
Clean-up is easier in threaded systems
Heap allocation in events together with error
branching in control flow makes it difficult to clean
Rania Elnaggar 19
Compiler support to overcome performance
Dynamic stack growth
Live state management
Rania Elnaggar 20
Knot – How does it scale?
Rania Elnaggar 21
Rania Elnaggar 22
What is the “best” answer?
Yet to be found!
There is no “best”
answer. It is only “an”
Rania Elnaggar 23
CMP is mainstream
True concurrency is cheap
Complex specialty architectures (ex: NUMA) will
be less attractive
No distinction between data and operations
Encapsulated Entities – No locking nightmares!
New languages and new compilers.
Hybrid models? New models?
Rania Elnaggar 24
Thank you for staying tuned!
Rania Elnaggar 25