Multiprocessor Support for Event-Driven Programs
Nickolai Zeldovich, Alexander Yip, Frank Dabek, Robert T Morris, David Mazières, Frans Kaashoek MIT Laboratory for Computer Science Usenix Technical, June 2003
Multiprocessor Support for Event-Driven Programs Nickolai - - PowerPoint PPT Presentation
Multiprocessor Support for Event-Driven Programs Nickolai Zeldovich, Alexander Yip, Frank Dabek, Robert T Morris, David Mazires, Frans Kaashoek MIT Laboratory for Computer Science Usenix Technical, June 2003 Introduction Many internet
Nickolai Zeldovich, Alexander Yip, Frank Dabek, Robert T Morris, David Mazières, Frans Kaashoek MIT Laboratory for Computer Science Usenix Technical, June 2003
– Code consists of many callback functions, which
are executed when an event occurs
– Events can be a mouse click, receiving network
data, timer expiration, ...
– Callback functions perform some task and can
register other callbacks waiting for new events
– Code is never executed in parallel – Programmer can be confident that his callback is
the only one changing the state right now
– Can't just break a fundamental assumption
– A color is any integer value – Callbacks of the same color can't run in parallel – Callbacks of different colors can run in parallel
– Programmer has to explicitly break things
– Mutex locks are hard: deadlocks, race conditions – Not worrying about concurrency and locking is a
big advantage in event-driven programs!
– Callbacks in event-driven programs should not
block; acquiring a mutex does
– Callbacks typically perform short, well-defined
– Systems software often has natural coarse-
grained parallelism (e.g. many independent requests)
– With threads and mutex locks, it's all-or-nothing
– void cbfunc (char x, int y);
callback cb = wrap (&cbfunc, 'A'); cb (7); /* executes cbfunc ('A', 7) */
– Great for modularity
while (Q.head) Q.head (); while (Q.head) Q.head ();
CPU 1 CPU 2 ... ...
– Executed by a worker thread when there are no
– Calls select() and enqueues other callbacks as
necessary
– Callbacks of the same color run in same worker
thread
– Color-to-worker affinity improves cache locality,
like thread-to-CPU affinity in kernel scheduler
– Improves cache locality
– Must steal all callbacks of the same color
– Count lines of code changed or written – Count number of callbacks colored
– NFS file handle cache – Web page cache
to allow simultaneous access to different pages
– libasync-smp based event-driven server – Same web server using unmodified libasync,
running a separate copy on each CPU (``N- copy'')
– Apache 2.0.36 – Flash v0.1.990914