Presentation is loading. Please wait.

Presentation is loading. Please wait.

Paper Review of Why Events Are A Bad Idea (for high-concurrency servers) Rob von Behren, Jeremy Condit and Eric Brewer By Anandhi Sundaram.

Similar presentations


Presentation on theme: "Paper Review of Why Events Are A Bad Idea (for high-concurrency servers) Rob von Behren, Jeremy Condit and Eric Brewer By Anandhi Sundaram."— Presentation transcript:

1 Paper Review of Why Events Are A Bad Idea (for high-concurrency servers) Rob von Behren, Jeremy Condit and Eric Brewer By Anandhi Sundaram

2 CS533 - Concepts of Operating Systems 2 THE STAGE  Highly Concurrent Applications o Internet Servers o Transaction Processing Databases  Challenges Posed o Large numbers of Concurrent tasks, require scalable Data Structures o Operate near max capacity, Resource Contention, Scheduling Sensitivity o Inevitable Overload, must be handled to avoid thrashing, well- conditioned o Race Conditions, Code Complexity Ideal Peak: some resource at max Overload: some resource thrashing Load (concurrent tasks) Performance

3 CS533 - Concepts of Operating Systems 3 Events are Better  Recent Arguments for Events o Inexpensive synchronization due to co-operative multitasking o Lower Overhead for managing state (no stacks) o Better scheduling and locality o More Flexible Control Flow  True But o All above properties can be implemented in Threads o Problem is with Thread Implementations, and not Threads

4 CS533 - Concepts of Operating Systems 4 Overcoming the “Problems” with Threads  Performance  Criticism: Threads don’t perform well for high concurrency  Reasons : o Presence of O(n) thread operations o High Context Switch overhead  Response o Avoid O(n) operations o Co-operative Multi-tasking

5 CS533 - Concepts of Operating Systems 5 Simple Scalability Test  Slightly modified GNU Pth  Removed O(n) operations from scheduler  Thread-per-task Vs Single Thread  Same Performance

6 CS533 - Concepts of Operating Systems 6 Overcoming the “Problems” with Threads  Control Flow  Criticism: Threads have restrictive Control flow  Response: Code Structure of Web Server and applications fall under three simple categories - call/return - Parallel Calls - Pipeline Threads express the above more naturally Complex Patterns are unnatural, hard to understand, Error-prone

7 CS533 - Concepts of Operating Systems 7 Overcoming the “Problems” with Threads  Synchronization  Criticism: Thread Synchronization mechanisms are too heavyweight  Response : o Co-operative Multitasking works for threads too o Compiler Support in MultiProcessor Systems

8 CS533 - Concepts of Operating Systems 8 Overcoming the “Problems” with Threads  State Management  Criticism: Thread Stacks are an ineffective way to manage live state  Response : o Compiler support for Dynamic Stack Growth o Compiler support for better Live State Management o Entire frame could be popped in case of tail call o Variables with overlapping lifetimes could be moved off stack o Compiler warns about inefficiency

9 CS533 - Concepts of Operating Systems 9 Overcoming the “Problems” with Threads  Scheduling  Criticism: Thread schedulers are too generic o Can’t use application-specific information  Response o 2D scheduling: task & program location Threads schedule based on task only Events schedule by location (e.g. SEDA) –Allows batching, prediction for SRCT o Resource Aware Scheduling in Capriccio Runtime system tracks current location Block graph allows prediction Task Program Location Threads Events

10 CS533 - Concepts of Operating Systems 10 The Case For Threads  Observations About Modern Servers o Concurrent Requests are Largely Independent o Code handling each request is Sequential  Threads – A more Natural Programming Model o Express Better Control Flow o Automatic State Management o Exception Handling Easier in Threads

11 CS533 - Concepts of Operating Systems 11 The Case for Threads  Lots of Infrastructure for Threads o Debuggers, Languages, Compilers  Consequences o More amenable to Analysis o Less effort to get working systems

12 CS533 - Concepts of Operating Systems 12 The Duality Argument  Two Models are Duals of Each other  With Good Practices both approaches should yield equivalent performance o No inherent problem with threads! o Equivalent Good Thread implementations possible  Thread-based approach is preferrable o More natural Programming Model o Co-operative multitasking threads o Compiler Support

13 CS533 - Concepts of Operating Systems 13 Evaluation  User-level cooperative threads package o Minimal context switching o Converts Blocking I/O to Asynchronous I/O o No O(n) operations o Support > 100K threads  Simple web server: Knot  Knot-A : Favors accepting new clients over processing  Knot-C : Favors processing existing clients over accepting new clients

14 CS533 - Concepts of Operating Systems 14 Evaluation  Compared performance of Haboob with Knot-A, Knot-C o The Steady-state bandwidth of Knot-C higher than Haboob o Performance degradation of Knot-A, Haboob is due to poor scalability of poll() o Haboob ran out of memory with 16384 clients 0 100 200 300 400 500 600 700 800 900 1 4 16 64 256 1024 4096 16384 KnotC (Favor Connections) KnotA (Favor Accept) Haboob Concurrent Clients Mbits / second

15 CS533 - Concepts of Operating Systems 15 Evaluation  Reasons for Haboob’s Poor Performance o Haboob’s context switches 6X times as Knot o Large number of queueing operations o Relies heavily on garbage collection o Ambiguous control flow, reduces compiler optimization, increases CPU-stalls Conclusion : A well-designed thread package can achieve the same scaling behaviour as a well-designed event system.

16 CS533 - Concepts of Operating Systems 16 References  1. Why Events are a Bad Idea (for high-concurrency servers), Rob von Behren, Jeremy Condit, and Eric Brewer. In Proceedings of the 10th Workshop on Hot Topics in Operating Systems (HotOS IX), Lihue, Hawaii, May 2003. [pdf]pdf http://warthog.cs.berkeley.edu/pubs/threads_hotos_2003_slides.ppt  2. On the Duality of Operating System Structures, Hugh C.Lauer, Roger M.Needham  3. Event Driven Programming for Robust Software, Frank Dabek, Nickolai Zeldovich, Frans Kaashoek, David Mazieres, Robert Morris  4. SEDA: An Architecture for Well-Conditioned, Scalable Internet Services, Matt Welsh, David Culler, and Eric Brewer  5. Capriccio: Scalable Threads for Internet Services, Rob von Behren, Jeremy Condit, Feng Zhou, George C. Necula, and Eric Brewer. In Proceedings of the Ninteenth Symposium on Operating System Principles (SOSP-19), Lake George, New York. October 2003 http://warthog.cs.berkeley.edu/pubs/capriccio-sosp-2003.pdf

17 CS533 - Concepts of Operating Systems 17 References  GNU Pth – The GNU Portable Threads http://www.gnu.org/software/pth


Download ppt "Paper Review of Why Events Are A Bad Idea (for high-concurrency servers) Rob von Behren, Jeremy Condit and Eric Brewer By Anandhi Sundaram."

Similar presentations


Ads by Google