2 ms·
Indeed. And the corollary is that every possible performance benefit of non-blocking code is in principle achievable with threaded code, though some of the sche
by barrkel 16y ago
Indeed. And the corollary is that every possible performance benefit of non-blocking code is in principle achievable with threaded code, though some of the scheduler may need to be implemented in userland, with more explicit hinting of things like lifetimes of local variables in stack frames, etc., to get there. The true benefit of event-oriented network programming may be simply in what it makes explicit vs implicit. By making the tracking of state awkward, it forces its minimization and consolidation. By a process of Worse is Better, it ends up being more performant for scaling despite (usually) being more awkward to program (especially if you have any kind of nesting or recursion structure in your protocol).
- ankrgyl 16y agoRemember that modern implementations of kernel threads are designed to be general-purpose. So, while a threaded model would solve the problems, it also incurs necessary overhead (that works towards solving irrelevant problems). The event-driven approach can be thought of as minimalistic user-space threads for this context. Libraries like Python Eventlet (http://eventlet.net/ http://eventlet.net/) and CML (http://cml.cs.uchicago.edu/ http://cml.cs.uchicago.edu/) are trying to reabstract this into the conveniences of thread-style programming.