Presenter: Godmar Back

Slides:



Advertisements
Similar presentations
3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process An operating system executes a variety of programs: Batch system.
Advertisements

Process management Information maintained by OS for process management  process context  process control block OS virtualization of CPU for each process.
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.
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.
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.
Processes CSCI 444/544 Operating Systems Fall 2008.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
CS 3013 & CS 502 Summer 2006 Scheduling1 The art and science of allocating the CPU and other resources to processes.
Precept 3 COS 461. Concurrency is Useful Multi Processor/Core Multiple Inputs Don’t wait on slow devices.
Capriccio: Scalable Threads for Internet Services (von Behren) Kenneth Chiu.
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.
Threads 1 CS502 Spring 2006 Threads CS-502 Spring 2006.
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,
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
SEDA: An Architecture for Well-Conditioned, Scalable Internet Services
Implementing Processes and Process Management Brian Bershad.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Threads and Processes.
SEDA: An Architecture for Well-Conditioned, Scalable Internet Services Presented by Changdae Kim and Jaeung Han OFFENCE.
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.
1 Combining Events and Threads for Scalable Network Services Peng Li and Steve Zdancewic University of Pennsylvania PLDI 2007, San Diego.
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)
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
CSE 60641: Operating Systems Next topic: CPU (Process/threads/scheduling, synchronization and deadlocks) –Why threads are a bad idea (for most purposes).
6.894: Distributed Operating System Engineering Lecturers: Frans Kaashoek Robert Morris
Capriccio: Scalable Threads for Internet Service
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.
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.
Paper Review of Why Events Are A Bad Idea (for high-concurrency servers) Rob von Behren, Jeremy Condit and Eric Brewer By Anandhi Sundaram.
Embedded Real-Time Systems
Capriccio:Scalable Threads for Internet Services
CS 3214 Computer Systems Lecture 9 Godmar Back.
Capriccio : Scalable Threads for Internet Services
Threads vs. Events SEDA – An Event Model 5204 – Operating Systems.
Why Events Are A Bad Idea (for high-concurrency servers)
CS 6560: Operating Systems Design
Processes and Threads Processes and their scheduling
Lecture Topics: 11/1 Processes Process Management
CS399 New Beginnings Jonathan Walpole.
Chapter 4 Threads.
Capriccio – A Thread Model
Process management Information maintained by OS for process management
PROCESS MANAGEMENT Information maintained by OS for process management
Processes and Process Management
Capriccio: Scalable Threads for Internet Services
Why Threads Are A Bad Idea (for most purposes)
Why Events Are a Bad Idea (for high concurrency servers)
CSE 153 Design of Operating Systems Winter 2019
CS703 - Advanced Operating Systems
Why Threads Are A Bad Idea (for most purposes)
Why Threads Are A Bad Idea (for most purposes)
CS703 – Advanced Operating Systems
Operating System Concepts
Operating System Concepts
Light-Weight Process (Threads)
CS 5204 Operating Systems Lecture 5
Threads.
Presentation transcript:

Presenter: Godmar Back CS 5204 Capriccio: Scalable Threads for Internet Services by von Behren et al Presenter: Godmar Back

What Happened So Far 1978 Lauer & Needham Duality – event-based and thread-based models are duals Can transform programs from one to the other Can preserve performance after transformation This did not settle the issue Fast forward 18 years to 1996: Internet is becoming popular; multi-threaded OS become commonplace

Why Threads Are A Bad Idea 1996 talk by John Ousterhout: “Why threads are a bad idea” Threads are hard to program (synchronization error-prone, prone to deadlock, convoying, etc.); experts only Threads can make modularization difficult Thread implementations are hard to make fast Threads aren’t well-supported (as of 1996) (Ousterhout’s) Conclusion: use threads only when their power is needed - for true CPU concurrency on an SMP – else use single-threaded event-based model CS 5204 Fall 2007 9/8/2018

Thread/process-based Server Models Option A: fork a new process for every connection on-demand Option B: fork a new thread for every connection to handle it Option C/D: pre-fork a certain number of processes (or threads) and hand connections to them

Server Models (2) A B C D A/B: # grows & shrinks C/D: fixed # Q.: When would you use which?

Most Widely Used Servers 1995-2007 (Source: netcraft.com) Typical Apache Pre-forked model, usually 5-25 processes

The /. effect Sudden spikes in load Need to build scalable server systems Even without /. effect, better scalability means better cost efficiency Q.: Which model provides highest throughput, given a fixed set of hardware resources, while providing for a robust and understandable programming model?

High-Concurrency Servers Ideal Peak: some resource at max Overload: some resource thrashing Load (concurrent tasks) Performance Source: von Behren [2003] Key goal: Maintain throughput: measure of useful work seen by clients CPU and resource management is critical Must weigh which connections to accept vs. to drop Ensure that requests in pipeline are completed

Motivation for Events Source: Walsh 2001, Performance results in LinuxThreads (pre-NPTL) NB: thread packages no longer perform this poorly.

Flash (Pai et al 1999) Fast event-based WebServer Uses Unix select() call to multiplex network connections Used helper processes for disk I/O Now could use Linux aio For more recent alternatives, see [Chandra Mosberger 2001] and Kegel’s “C10k” site at http://www.kegel.com/c10k.html

Event-based Model (Walsh et al 2001) : SEDA Stages: Explicit resource and concurrency control

Capriccio Thread-based model widely used: Allows linear control flow Event-based model has been shown to outperfom thread-based model Q.: is it possible to get performance of event-based model while maintaining ease of programming of threaded model? Fix underlying threading system! (And nevermind Ousterhout: “Why Events Are A Bad Idea [Behrens 2003])

Idea: Write scalable threading package What scalability issues plague threading packages? (a) Memory costs for many thread stacks – particularly, virtual memory (b) High cost of context-switching (c) Lack of explicit load control (all load looks to the scheduler like a “runnable thread”)

Capriccio Solutions (a) Use Linked Stacks (b) Use user-level threading (c) Deduce resource usage from blocking graph

(a) Linked Stacks Compiler assumes that stack is unlimited and continous: “sub $n, esp; mov _, (esp)” will never fail. Moreover, stack is not movable Usually do static, conservative (worst-case) allocation - leads to increased virtual memory use (+fragmentation) on 32-bit systems Linux: 4GB total, 3GB for processes, some needed for heap, shared libraries, code, etc. Say 2GB left for threads. Each stack 128KB -> maximum 65,536 threads. Idea: allocate stack space on demand Change compiler to do so

Compiler Analysis Whole-program analysis computes a static, weighted call graph Nodes: functions Edges: call-sites Node weight: size of activation record of that function

Computing Node Weights Compute size of local vars int sample() { int a, b; int c[10]; double d; char e[8036]; return 0; }

Sizing stack chunks Extremes: Allocate all stack space beforehand would only work if no recursion is present Even then, huge external wasted space Allocate each function’s stack space as it is entered Extremely expensive No external wasted space Configurable parameters: allocate at least “MinChunk” for each stack piece, and introduce breaks either on recursion, or to break path after length “MaxPath”

Example main(){char buf[512]; A(); C();} void A(){char buf[820]; B(); D();} void B(){char buf[1024];} void C(){char buf[205]; D(); E();} void D(){char buf[205];} void E(){char buf[205]; C();}

External vs. Internal Wastage MaxPath = 1KB, MinChunk 1 KB. Internal Waste External Waste

(b) User-level Threading Capriccio uses highly-efficient, non-preemptive (cooperative) user-level threading. Scheduler works like event loop: “waits” for one or more fds to be ready, schedules thread waiting on this fd. Scalable data structures Pays slight price for asynchronous I/O at user level

(c) Blocking Graphs Resource needs are deduced from blocking graph Close Write Read Open Accept Web Server Resource needs are deduced from blocking graph Node represented program points + backtraces Edges annotated with time it takes to go from node to node Monitors and schedules resources associated with blocking points

Performance Results 15% speedup with Capriccio