Diving into the Loop
This is a talk on the inner workings of the mighty event loop, which forms the backbone of services as ubiquitous and powerful as nginx, HAProxy and node.js. With new concurrency paradigms like Go (which contributed to a renaissance of the m:n scheduling model) and Scala (based on the actor model) emerging, what's the future of single threaded, evented async I/O?
The event loop, however, isn't just limited to what's commonly considered single threaded languages, runtimes and frameworks. It at the core of various other concurrency models as well, and even when operating in a multithreaded world, it's possible to have components written in the evented style. For instance, Rust's mio implements an event loop, but allows for thread safe message channels for communication across threads.
This talk would explore the implementation of the event loop on Linux and BSD - with epoll and kqueue -- as well as some of the primitives built atop the API it exposes. We'll look at the implementation of a very common abstraction that can be found in many languages and frameworks -- the coroutine -- and understand how they actually work. We'll then explore how languages that offer a different concurrency model still rely on the event loop for several core functionalities, using Go's network poller and Java's Netty and Rust's mio library as case studies. We'll then further explore optimizations for building high throughput, low latency services on top of the event loop.