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]

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

Chess Review May 8, 2003 Berkeley, CA Compiler Support for Multithreaded Software Jeremy ConditRob von Behren Feng ZhouEric Brewer George Necula.
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.
Chapter 4: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads.
Why Events Are A Bad Idea (for high-concurrency servers) By Rob von Behren, Jeremy Condit and Eric Brewer.
1 On the Duality of Operating System Structures by Hugh C. Lauer, Xerox Corporation and Roger M. Needham, Cambridge University Presented by Scott Fletcher.
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.
CS533 Concepts of Operating Systems Class 6 The Duality of Threads and Events.
Scheduler Activations Effective Kernel Support for the User-Level Management of Parallelism.
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
Threads CSCI 444/544 Operating Systems Fall 2008.
“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,
 2004 Deitel & Associates, Inc. All rights reserved. Chapter 4 – Thread Concepts Outline 4.1 Introduction 4.2Definition of Thread 4.3Motivation for Threads.
CS533 Concepts of Operating Systems Class 3 Integrated Task and Stack Management.
A. Frank - P. Weisberg Operating Systems Introduction to Tasks/Threads.
Why Events Are A Bad Idea (for high-concurrency servers) Rob von Behren, Jeremy Condit and Eric Brewer Computer Science Division, University of California.
CS 3013 & CS 502 Summer 2006 Threads1 CS-3013 & CS-502 Summer 2006.
1 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
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,
CS 153 Design of Operating Systems Spring 2015
Parallel Programming Models Jihad El-Sana These slides are based on the book: Introduction to Parallel Computing, Blaise Barney, Lawrence Livermore National.
Threads, Thread management & Resource Management.
SEDA: An Architecture for Well-Conditioned, Scalable Internet Services Presented by Changdae Kim and Jaeung Han OFFENCE.
Lecture 2 Foundations and Definitions Processes/Threads.
Scheduler Activations: Effective Kernel Support for the User- Level Management of Parallelism. Thomas E. Anderson, Brian N. Bershad, Edward D. Lazowska,
 2004 Deitel & Associates, Inc. All rights reserved. 1 Chapter 4 – Thread Concepts Outline 4.1 Introduction 4.2Definition of Thread 4.3Motivation for.
Concurrent Programming. Concurrency  Concurrency means for a program to have multiple paths of execution running at (almost) the same time. Examples:
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.
Review The Joys and Pains of Threads and Multithreading –what is a thread –threads vs. processes –opportunities and risks.
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
M. Accetta, R. Baron, W. Bolosky, D. Golub, R. Rashid, A. Tevanian, and M. Young MACH: A New Kernel Foundation for UNIX Development Presenter: Wei-Lwun.
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).
1 Cooperative Task Management without Manual Stack Management or Event-driven Programming is not the Opposite of Threaded Programming Atul Adya, Jon Howell,
13-1 Chapter 13 Concurrency Topics Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads C# Threads.
Thread basics. A computer process Every time a program is executed a process is created It is managed via a data structure that keeps all things memory.
Threads-Process Interaction. CONTENTS  Threads  Process interaction.
By: Rob von Behren, Jeremy Condit and Eric Brewer 2003 Presenter: Farnoosh MoshirFatemi Jan
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.
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.
Contents 1.Overview 2.Multithreading Model 3.Thread Libraries 4.Threading Issues 5.Operating-system Example 2 OS Lab Sun Suk Kim.
Chapter 4 – Thread Concepts
Threads & Multithreading
Threads vs. Events SEDA – An Event Model 5204 – Operating Systems.
Why Events Are A Bad Idea (for high-concurrency servers)
On the Duality of Operating System Structures
Chapter 4 – Thread Concepts
CS399 New Beginnings Jonathan Walpole.
Presentation by Omar Abu-Azzah
Presenter: Godmar Back
Capriccio – A Thread Model
Chapter 4: Threads.
Why Events Are a Bad Idea (for high concurrency servers)
CS 5204 Operating Systems Lecture 5
Presentation transcript:

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] Some slides from Rania Elnaggar [2] Questions from you [3] On the Duality of Operating System Structures. Hugh C. Lauer, et al. [4] Cooperative task management without manual stack management. A. Adya, et al.

Agenda Debate (Threads vs Events) Overview Looking insight into Threads’ problems Threads vs. Events for programming high- currency servers Evaluation( Knot vs. Haboob) Conclusion & Discussion

Debate between threads and events Camp ThreadsCamp Events Events are WORSE! Threads are BAD! 1978, Lauer and Needham, “On the Duality of Operating System Structures” 1996, John K. Ousterhout, “why threads are a bad idea (for most purposes)” SOSP 2001, Eric Brewer’s group, “SEDA” SOSP 2003, Eric Brewer’s group, “Capriccio”; Hot Os 2003, “Whey events are a bad idea (for high-concurrency servers)” USENIX ATC 2004, “Lazy AIO for event- driven servers” pic,. from Rania Elnaggar “The principal conclusion is that neither model is inherently preferable, and the main consideration for choosing between them is the nature of the machine architecture upon which the system is being built, … Is it a dichotomy?

Criticism of Threads 1: Poor Performance O(n) operations. n is #threads Relative high context switching overhead comparing to events. Argument: Artifact of poor threading implementation. Not intrinsic properties of threads. Questionss/Discussion the author's threaded server collapsing after concurrent tasks, while the event-based server maintains its performance level. is this still just an 'artifact of a poor thread implementation' or do event-based systems handle load 'better'?

Criticism of Threads 2: Control Flow Too “linear” control flow: restrictive Argument 1: Control flow patterns used by “Flash, applications in Ninja, SEDA, and Tiny Os” fall into three simple categories: Call/return, parallel calls and pipelines They all can be easily implemented with threads Argument 2: More complex patterns are difficult to use, and are more likely to lead error. Argument 3: Dynamic fan-in and fan-out is less graceful here but not used by highly concurrcy servers.

Criticism of Threads 3: Synchronization Too heavy-weight! Events system use cooperative multitasking get “free” synchronization! Argument: Cooperative multitasking can also be used in thread systems. Questions/Discussions Isn‘t the single largest advantage and difficulty of threads the synchronization issue and the fact that they offer true concurrency? Cooperative multi-tasking appears to negate a large part of why we use threads. And in a multi- processor world, is it a feasible solution?

Criticism of Threads 4: State Management “Thread stacks are an ineffective way to manage live state. – Large stack: wasting virtual address space; – Small stack: stack overflow Rescue: Propose a mechanism that will enable dynamic stack growth. (Capriccio)

Criticism of Threads 5: Scheduling Event systems can schedule event deliveries at application level, which is benefit for efficient scheduling. Event systems allow better code locality by running several of the same kind of event in a row. Argument: Thread system can also apply the same scheduling tricks to cooperatively scheduled threads.

Discussion This paper hints, though does not explicitly state, that a user-level threading package is the only practical way to achieve the scheduling goals —primarily, that to avoid difficult synchronization and locking, threads should yield only at specific, known locations, such as explicit yields and blocking system calls. Is there a possibility of kernel-level threading accomplishing the same thing? I think offering the task of managing the state to the user is better than letting the OS to do this thing, even OS can use a heuristic Algorithm.

High- concurrency Servers Group call/return: More natural Run-time call stack encapsulate all live state for a task  easy debugging Obfuscate the control flow; Stack Ripping; Lead to subtle race conditions and logic errors due to unexpected message arrivals. Usually, task state is heap allocated. Difficult to clean up because braches of the program. Garbage collection is inappropriate for high-performance systems. Easy to clean up task state after exception and normal termination Control Flow Task State Fixing the problems of events is tantamount to switching to threads. What is stack ripping? EventsThreads How is the complexity of debugging in thread-based systems? The paper just simply claims that thread is a natural way to program while ignoring the difficulty in thread debugging?

Compiler Support Dynamic Stack Growth. – The stack can be adjusted at run time – (Refer to Capriccio) Live State Management Synchronization – Warn the programmer about data races – Example: nesC Support atomic sections Understands the concurrency model Information can be given to the runtime system to allow safe execution on multiprocessors. Questions/Discussion Except nesC, does this powerful compiler really exist? Or will it show up in the future? Is there anything else the current compiler can help the thread programming?

Evaluation Questions It seems that the high performance of Knot-C comes from its policy, which is to serve existing connections and reject new ones. So is it possible that we apply such policy on Haboob so that it can get a comparable performance to Knot-C? Implemented using Coro coroutine 1.Minimize context switch 2.Translate blocking I/O requests to asynchronous requests internally. (/dev/poll) Knot: 700-line web server The same test suit to evaluate SEDA

Conclusion From this paper – Simple programming model – Wealth of compiler analyses – Tight integration between the compiler and the thread system. What do you think? Which one is better? Threads or Events? Or it depends.

Discussion Prevalence of Multi-core – Threads or Event programming model? – Other programming model? – OS changed? – New programming language? – New Compiler? A good opportunity to revise the whole software stack!

Thanks for your attention!

Backup slides

17From Rania Elnaggar Event-based model “Classic” definition: -- “Message-passing model” – Small number of static processes – Specific communication paths (channels, ports) – Address space is divided – Synchronization and cooperation through message passing, therefore, known as message-passing model – No “mutual” sharing of data – Blocked I/O is complex to handle. Stack ripping. E.g: SEDA

18From Rania Elnaggar The Pseudo-concurrent model Scheduler Handler 1 Handler 2 Handler 3 Handler 4

19From Rania Elnaggar Thread-based model “Classic” definition: – Large number of dynamic light-weight processes (i.e. threads) – Classically procedure-oriented through fork and join – Synchronization via shared data and interlocking. – System resources encoded as global data structures and shared via locks – Blocked I/O is a blocked thread. State saved in thread context.

20From Rania Elnaggar The Quasi-concurrent model 123n Shared resources & address space