1 Why Events Are A Bad Idea (for high-concurrency servers) By Rob von Behren, Jeremy Condit and Eric Brewer (May 2003) CS533 – Spring 2006 – DONG, QIN.

Slides:



Advertisements
Similar presentations
CS 443 Advanced OS Fabián E. Bustamante, Spring 2005 Cooperative Task Management without Manual Stack Management or Event-driven programming is not the.
Advertisements

Capriccio: Scalable Threads for Internet Services Rob von Behren, Jeremy Condit, Feng Zhou, Geroge Necula and Eric Brewer University of California at Berkeley.
Chess Review May 8, 2003 Berkeley, CA Compiler Support for Multithreaded Software Jeremy ConditRob von Behren Feng ZhouEric Brewer George Necula.
1 SEDA: An Architecture for Well- Conditioned, Scalable Internet Services Matt Welsh, David Culler, and Eric Brewer Computer Science Division University.
CS533 Concepts of Operating Systems Jonathan Walpole.
1 Capriccio: Scalable Threads for Internet Services Matthew Phillips.
SEDA: An Architecture for Well- Conditioned, Scalable Internet Services Matt Welsh, David Culler, and Eric Brewer Computer Science Division University.
Concurrency, Thread and Event CS6410 Sept 6, 2011 Ji-Yong Shin.
Chapter 5 Processes and Threads Copyright © 2008.
Why Events Are A Bad Idea (for high-concurrency servers) By Rob von Behren, Jeremy Condit and Eric Brewer.
SEDA: An Architecture for Well-Conditioned, Scalable Internet Services Matt Welsh, David Culler, and Eric Brewer Computer Science Division University of.
Capriccio: Scalable Threads for Internet Services ( by Behren, Condit, Zhou, Necula, Brewer ) Presented by Alex Sherman and Sarita Bafna.
Capriccio: Scalable Threads for Internet Services Rob von Behren, Jeremy Condit, Feng Zhou, George Necula and Eric Brewer University of California at Berkeley.
Capriccio: Scalable Threads for Internet Services Rob von Behren, Jeremy Condit, Feng Zhou, Geroge Necula and Eric Brewer University of California at Berkeley.
3.5 Interprocess Communication Many operating systems provide mechanisms for interprocess communication (IPC) –Processes must communicate with one another.
Threads 1 CS502 Spring 2006 Threads CS-502 Spring 2006.
3.5 Interprocess Communication
Why Events Are a Bad Idea (for high-concurrency servers) Author: Rob von Behren, Jeremy Condit and Eric Brewer Presenter: Wenhao Xu Other References: [1]
“Why Events are a Bad Idea (For high-concurrency servers)” Paper by Rob von Behren, Jeremy Condit and Eric Brewer, May 2003 Presentation by Loren Davis,
Concurrency, Threads, and Events Robbert van Renesse.
 2004 Deitel & Associates, Inc. All rights reserved. Chapter 4 – Thread Concepts Outline 4.1 Introduction 4.2Definition of Thread 4.3Motivation for Threads.
Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Silberschatz, Galvin and Gagne ©2007 Chapter 4: Threads.
CS533 Concepts of Operating Systems Class 2 The Duality of Threads and Events.
Why Events Are A Bad Idea (for high-concurrency servers) Rob von Behren, Jeremy Condit and Eric Brewer Computer Science Division, University of California.
On the Duality of Operating System Structures Hugh C. Lauer Xerox Corporation Roger M. Needham Cambridge University Presented By: Ashwini Kulkarni.
Why Events Are A Bad Idea (for high-concurrency servers) Rob von Behren, Jeremy Condit and Eric Brewer University of California at Berkeley
SEDA: An Architecture for Well-Conditioned, Scalable Internet Services
Why Events Are A Bad Idea (for high-concurrency servers) Rob von Behren, Jeremy Condit and Eric Brewer Presented by: Hisham Benotman CS533 - Concepts of.
Cooperative Task Management without Manual Stack Management Or, Event-driven Programming is not the Opposite of Thread Programming Atul Adya, John Howell,
SEDA: An Architecture for Well-Conditioned, Scalable Internet Services
1 Lecture 4: Threads Operating System Fall Contents Overview: Processes & Threads Benefits of Threads Thread State and Operations User Thread.
Threads, Thread management & Resource Management.
Dave Archer - CS533 - Spring On the Duality of Operating System Structures Hugh C. Lauer, Roger M. Needham.
SEDA: An Architecture for Well-Conditioned, Scalable Internet Services Presented by Changdae Kim and Jaeung Han OFFENCE.
 2004 Deitel & Associates, Inc. All rights reserved. 1 Chapter 4 – Thread Concepts Outline 4.1 Introduction 4.2Definition of Thread 4.3Motivation for.
CS533 - Concepts of Operating Systems 1 On The Duality of Operating System Structures Hugh Lauer, Xerox Roger Needham, Cambridge University 1979 Presented.
Capriccio: Scalable Threads for Internet Services Rob von Behren, Jeremy Condit, Feng Zhou, Geroge Necula and Eric Brewer University of California at Berkeley.
CS333 Intro to Operating Systems Jonathan Walpole.
Lecture 5: Threads process as a unit of scheduling and a unit of resource allocation processes vs. threads what to program with threads why use threads.
5204 – Operating Systems Threads vs. Events. 2 CS 5204 – Operating Systems Forms of task management serial preemptivecooperative (yield) (interrupt)
Department of Computer Science and Software Engineering
Presenting: Why Events Are A “Bad” Idea ( for high-concurrency servers) Paper by: Behren, Condit and Brewer, 2003 Presented by: Rania Elnaggar 1/30/2008.
CSE 60641: Operating Systems Next topic: CPU (Process/threads/scheduling, synchronization and deadlocks) –Why threads are a bad idea (for most purposes).
Processes & Threads Introduction to Operating Systems: Module 5.
1 Cooperative Task Management without Manual Stack Management or Event-driven Programming is not the Opposite of Threaded Programming Atul Adya, Jon Howell,
SEDA: An Architecture for Well-Conditioned, Scalable Internet Services Matt Welsh, David Culler, and Eric Brewer Computer Science Division University of.
By: Rob von Behren, Jeremy Condit and Eric Brewer 2003 Presenter: Farnoosh MoshirFatemi Jan
SEDA An architecture for Well-Conditioned, scalable Internet Services Matt Welsh, David Culler, and Eric Brewer University of California, Berkeley Symposium.
Holistic Systems Programming Qualifying Exam Presentation UC Berkeley, Computer Science Division Rob von Behren June 21, 2004.
Threads versus Events CSE451 Andrew Whitaker. This Class Threads vs. events is an ongoing debate  So, neat-and-tidy answers aren’t necessarily available.
CS533 Concepts of Operating Systems Jonathan Walpole.
1 Why Threads are a Bad Idea (for most purposes) based on a presentation by John Ousterhout Sun Microsystems Laboratories Threads!
Operating Systems Unit 2: – Process Context switch Interrupt Interprocess communication – Thread Thread models Operating Systems.
Paper Review of Why Events Are A Bad Idea (for high-concurrency servers) Rob von Behren, Jeremy Condit and Eric Brewer By Anandhi Sundaram.
Chapter 4 – Thread Concepts
SEDA: An Architecture for Scalable, Well-Conditioned Internet Services
Threads vs. Events SEDA – An Event Model 5204 – Operating Systems.
Why Events Are A Bad Idea (for high-concurrency servers)
Processes and Threads Processes and their scheduling
Chapter 4 – Thread Concepts
CS399 New Beginnings Jonathan Walpole.
Capriccio – A Thread Model
Chapter 4: Threads.
On the Duality of Operating System Structures
Fast Communication and User Level Parallelism
Capriccio: Scalable Threads for Internet Services
Structuring of Systems using Upcalls
Why Events Are a Bad Idea (for high concurrency servers)
CS703 – Advanced Operating Systems
CS 5204 Operating Systems Lecture 5
Presentation transcript:

1 Why Events Are A Bad Idea (for high-concurrency servers) By Rob von Behren, Jeremy Condit and Eric Brewer (May 2003) CS533 – Spring 2006 – DONG, QIN TINA

2 Arguments for Events & Threads Which One is better for high concurrent apps? Ousterhout In favor of using events; Support the use of threads for true CPU concurrency Welsh & Culler &Brewer SEDA (staged event-driven architecture) In favor of using events; But SEDA is designed with events and threads.

3 Arguments for Events & Threads Lauer and Needham Two strategies should yield equivalent performance. Message-oriented System (Events) Procedure-oriented System (Thread) event handlers events accepted by a handler SendMessage / AwaitReply SendReply waiting for messages Monitors functions exported by a module procedure call, or fork/join return from procedure waiting on condition variables

4 Arguments for Events & Threads Behren, Condit, Brewer (This paper authors) 1. Threads can perform as well as events for high concurrency. 2. Events don’t show substantial qualitative advantages. 3. The absence of scalable user-level threads is caused by an artifact of poor implementation rather than a basic property of the thread abstraction.

5 Behren’s arguments for events & threads: Are Events better ? In favor of eventsNot support events (This paper authors) Inexpensive synchronization due to cooperative multitasking; Lower overhead for managing state (no stacks); Better scheduling and locality (based on apps); flexible control flow (not just call/return) These properties could be implemented by threads as well.

6 Behren’s arguments for events & threads: Are threads bad? Performance. Threads - BadThreads – not Bad (This paper authors) O(n) in the number of threads. high context switch compared with events This disadvantages are not properties of threads Experiment: remove most of O(n) operations from the scheduler in GNU Pth user-level threading package, match SEDA’s performance.

7 Behren’s arguments for events & threads: Are threads bad? Control Flow Threads - BadThreads – not Bad (This paper authors) Threads have restrictive control flow. Analyze control flow patterns in Ninja, SEDA, Flash (call/return, parallel calls, and pipelines) These patterns could be expressed by threads as well. Thread Run-time call stack encapsulates all live state for a task (good for debugging)

8 Events – problem with control folw. (This paper authors) Events control flow requires mentally match call/return pairs, which could cause race condition / logic error due to unexpected message arrives. Events call/return requires manually save and restore live state. Control Flow

9 Behren’s arguments for events & threads: Are threads bad? - Synchronization Threads - BadThreads – not Bad (This paper authors) too heavyweightSupport Adya’s point: Event lightweight is due to cooperative multitasking, not events themselves. Threads could use lightweight as events do. Cooperative multitasking only provides sync on uni- processors (many high concurrency servers run on multiprocessors).

10 Behren’s arguments for events & threads: Are threads bad? - State Management Threads - BadThreads – not Bad (This paper authors) Thread stacks are an ineffective way to manage live state. Threads face tradeoff between risking stack overflow and wasting virtual address space on large stacks. Enabling dynamic stack growth could solve ineffective way to manage live state.

11 Behren’s arguments for events & threads: Are threads bad? - Scheduling Threads - BadThreads – not Bad (This paper authors) The virtual processor model forces the runtime system to be too generic and prevents it from making optimal scheduling decisions. Support Lauer-Needham's point : "we can apply the same scheduling tricks to cooperatively scheduled threads."

12 Behren’s arguments for events & threads: Threads is better : 1. Control Flow (Thread Run-time call stack encapsulates all live state for a task ) 2. Exception Handling and State Lifetime: Using threads: Easy cleaning up task state since the thread stack tracks the live state for the task. Using Events: a). Task state is typically heap allocated. Freeing this state at the correct time is extremely difficult. b). Garbage collection mechanism (used in SEDA) is inappropriate for high performance. Maintaining correct reference counting is difficult for managing state (used in Inktomi’s Traffic Server). 3. Even in existing event-driven systems is using threads for the most complex parts (eg. recovery) 4.The applications (not need high concurrency) are written with thread (eg, FTP server in Harvest) in many existing systems.

13 Idea with Compiler Support for Threads Developing a mechanism - Dynamic Stack Growth To avoid overflow / wasted space issues. 1. Compiler analysis provides an upper bound on the amount of stack space needed. 2. Compiler analysis helps determine which call sites may require stack growth. Live State Management Compilers could easily purge unnecessary state from the stack before making function calls. Synchronization 1. Compile analysis helps determine which atomic sections are safe to run concurrently. 2. Compile analysis can reduce the occurrence of bugs by warning the programmer about data races.

14 Evaluation Designed and implemented a simple a user-level cooperative threading package for Linux. 1. uses the coroutine library for minimalist context switching 2. translates blocking I/O requests to asynchronous requests internally. I. asynchronous socket I/O (use the UNIX poll() system call) II.asynchronous disk I/O (use a thread pool that performs blocking I/O operations) 3. The library also overrides blocking system calls and provides a simple emulation of pthreads. Design a test web server (Knot) with this thread pkg. accepts static data requests. allows persistent connections. includes a basic page cache.

15 Evaluation Comparison KnotHaboob user-level cooperative threading pkg Knot-C favors connections Knot-A favors accepting SEDA’s event-driven web server Have the same general performance patterns as Haboob Initially: linear increase in bandwidth as simultaneous connections increases; server saturated: the bandwidth levels out. Have the same general performance patterns as Knot. Initially: linear increase in bandwidth as simultaneous connections increases; server saturated: the bandwidth levels out.

16 Web server bandwidth versus concurrent clients (Failed to run in Haboob with clients >= 16384)

17 KnotHaboob The performance degradation in Knot-A is due to the poor scalability of poll(). The performance degradation in Haboob is due to the poor scalability of poll(). The steady-state bandwidth (Knot-C) is ~700 Mbit/s Maximum bandwidth is 500 Mbit/s: Why it is lower than Knot? requires more context switches (6 times than Knot) by thread pool per handler model create crossings and queuing operations by large # of small modules create many temporary objects and relie heavily on garbage collection. require various forms of run-time dispatch, since executing next event handler is unknown statically.

18 Conclusions A well designed thread package can achieve the same scaling behavior as a well-designed event system. Simpler programming model combined with compiler analyses could gives threads an advantage over events when writing highly concurrency Authors advocate tight integration between the compiler and the thread system