SlideShare une entreprise Scribd logo
1  sur  42
Télécharger pour lire hors ligne
Operating Systems
          CMPSCI 377
        Queuing Systems
            Emery Berger
University of Massachusetts Amherst




  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
Queuing Systems & Servers
    Queuing systems


        High-level model of concurrent applications
    

    Flux


        Language for building servers
    




        UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   2
Queuing Networks
    Model of tasks or services


        Node includes queue (line) & server
    




        UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   3
Queuing Networks
    Model of tasks or services


        Node includes queue (line) & server
    




        UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   4
Queuing Networks
    Model of tasks or services


        Node includes queue (line) & server
    




        UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   5
Queuing Networks
    Model of tasks or services


        Node includes queue (line) & server
    




        UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   6
Queuing Networks
    Model of tasks or services


        Node includes queue (line) & server
    




    arrival rate
        ()




        UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   7
Queuing Networks
    Model of tasks or services


        Node includes queue (line) & server
    




                        waiting time




        UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   8
Queuing Networks
    Model of tasks or services


        Node includes queue (line) & server
    




                                    service time




        UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   9
Queuing Networks
    Model of tasks or services


        Node includes queue (line) & server
    




        UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   10
Stable Systems
    Stable queuing system:


    arrival rate = departure rate




      UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   11
Stable Systems
    Stable queuing system:


    arrival rate = departure rate




      UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   12
Stable Systems
    Stable queuing system:


    arrival rate = departure rate




      UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   13
Stable Systems
    Stable queuing system:


    arrival rate = departure rate




    What happens if  > departure rate?





      UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   14
Stable Systems
    Stable queuing system:


    arrival rate = departure rate




    What happens if  > departure rate?





      UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   15
Stable Systems
    Stable queuing system:


    arrival rate = departure rate




    What happens if  > departure rate?





      UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   16
Stable Systems
    Stable queuing system:


    arrival rate = departure rate




    What happens if  > departure rate?





      UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   17
Networks of Queues
    Can build system from connected servers


        Latency = time for one thing to get through
    

        Throughput = service rate
    




        5/sec                          5/sec                              5/sec


    Throughput?


        UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science      18
Networks of Queues
    Can build system with numerous


    connected servers
        Latency = time for one thing to get through
    

        Throughput = service rate
    




        5/sec                          1/sec                              5/sec

    Throughput?


        Lowest throughput = bottleneck
    

        UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science      19
Little’s Law
    Little’s Law – applies to any “blackbox”


    server
        Queue length (N) =
    

        arrival rate () * average waiting time (T)
              N=T
          




              N

                                      T



        UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   20
Applications of Little’s Law
    Compute waiting time to get into


    restaurant, bar, etc.
        If N = 20 people in front of you,
    

         = departure rate = 1 / 5 min.,
        how long will you wait in line?



                                   N=T
             N

                                       T

        UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   21
Applications of Little’s Law
    Required service time?


        Arrival rate = one job @ 500 ms
    

        Average queue length = 10
    

        T=?
    

              What’s the average latency?
          




                                   N=T
              N

                                       T

        UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   22
Applications of Little’s Law
    Required service time?


        Arrival rate = one job @ 500 ms
    

        Average queue length = 5
    

        T=?
    

              What’s the average latency?
          




                                   N=T
              N

                                       T

        UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   23
Motivating Example: Image Server
                                                                       image
                                                                       server
    Client


        Requests image @ desired
    

        quality, size                                                               not found

    Server


        Images: RAW
    
                                              http://server/Easter-bunny/
                                              200x100/75
        Compresses to JPG
    

        Caches requests
    

        Sends to client
    




                                                  client
             UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
Problem: Concurrency
                                                                     image
    Could write sequential code                                      server

    but…
        More clients (latency)
    

        Bigger server
    

             Multicores, multiprocessors
         


    One approach: threads


        Limit reuse,
    

        risk deadlock,
        burden programmer
        Complicate debugging
    

        Mixes program logic &
    

        concurrency control                             clients

               UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
The Flux Programming Language
        High-performance & deadlock-free
concurrent programming w/ sequential components
     Flux = Components + Flow + Atomicity
 

         Components               unmodified C, C++ (or Java)
     

         Flow                     implicitly || path thru components
     

         Atomicity                high-level mutual exclusion
     



     Compiler generates:
 

         Deadlock-free, runtime-independent server
     

              Threads, thread pools, events, …
          


         Path profiling
     

         Discrete event simulator
     

                UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
Flux Outline

     Intro to Flux: building a server
 

         Components
     

         Flows
     

         Atomicity
     

     Performance results
 

         Server performance
     

         Performance prediction (QNMs)
     




         UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
Flux Server “Main”

    Source nodes originate flows


        Conceptually in separate thread
    

        Executes inside implicit infinite loop
    

             Here: initiates flow for each image request
         



                  source Listen  Image;




                      Listen
                                                           image server
                                                      ReadRequest      Compress       Write     Complete
                                                       ReadRequest      Compress       Write     Complete
                                                         ReadRequest     Compress       Write     Complete




               UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
Flux Image Server
     Basic image server requires:
 
        HTTP parsing (http)
      

       Socket handling (socket)

       JPEG compression (libjpeg)

       All UNIX-style C libraries

     Abstract node = flow across nodes
 
          Concrete or abstract
      



     Image = ReadRequest  Compress  Write  Complete;

     image server
                     ReadRequest            Compress              Write          Complete


                         http                libjpeg             socket            http

          UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
Control Flow
    Direct flow via user-supplied predicate types


         Type test applied to output
    

              Note: no variables – dispatch on output “type”
          


         Here: cache frequently requested images
    



typedef hit TestInCache;
Handler:[_,_,hit] = ;
Handler:[_,_,_] = ReadFromDisk  Compress  StoreInCache;


                                                  hit   handler
                   ReadRequest     CheckCache                                      Write     Complete
Listen


                         handler
                                                                              StoreInCache
                                      ReadInFromDisk        Compress



                 UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
Supporting Concurrency
    Many clients = concurrent flows


        Must keep cache consistent
    

    Atomicity constraints


        Same name = mutual exclusion
    

        Apply to nodes or whole flow (abstract node)
    


         atomic CheckCache                   {};
                                             {, };
         atomic Complete
         atomic StoreInCache                 {};

                                                            CheckCache hit
                                             ReadRequest                      Write      Complete
                                                              CheckCache hit     hit
                                               ReadRequest                      Write      Complete
                                                               CheckCache hit     Writehandler
                                                ReadRequest                                 Complete
                          Listen                  ReadInFromDisk     Compress       StoreInCache
                                                 ReadRequest          CheckCache      StoreInCache Write   Complete
                                                    ReadInFromDisk     Compress
                                                     ReadInFromDisk     Compress        StoreInCache

                                               handler
                                                                                                    StoreInCache
                                                              ReadInFromDisk         Compress




             UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
More Atomicity

    Reader / writer constraints


        Multiple readers or single writer (default)
    


              atomic ReadList: {listAccess?};
              atomic AddToList: {listAccess!};


    Per-session constraints


        User-supplied function ≈ hash on source
    

             Added to flow ≈ chooses from array of locks
         




             atomic AddHasChunk: {chunks(session)};
               UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
Preventing Deadlock

       Naïve execution can deadlock
   



       atomic A: {z,y};                                    atomic A: {y,z};
       atomic B: {y,z};                                    atomic B: {y,z};

       Establish canonical lock order
   

            Partial order
        

            Alphabetic by name
        




            UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   33
Preventing Deadlock, II
    Harder with abstract nodes


 A = B;
 C = D;
                             A:{z}
                             A
                             A{z}
 atomic A{z};                                                                C{y}
                                                                              C
                                           B
 atomic B{y};
 atomic C{y,z};

    Solution: Elevate constraints; fixed point


 A = B;
 C = D;                      A{y,z}
                                                                                  C
 atomic A{y,z};
                                           B
 atomic B{y};
 atomic C{y,z};

           UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science       34
Handling Errors
    What if image requested doesn’t exist?


        Error = negative return value from component
    

        Remember – nodes oblivious to Flux
    

    Solution: error handlers


        Go to alternate paths on error
    

        Possible extension – can match on error paths
    


         handle error ReadInFromDisk  FourOhFour;
                                                                            hit
                                                                                  handler
                                             ReadRequest        CheckCache                   Write    Complete


                              Listen       handler
                                                                                               StoreInCache
                                                           ReadInFromDisk         Compress




                                                                                     FourOhFour


             UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
Almost Complete Flux Image Server
source Listen  Image;
Image =
 ReadRequest  CheckCache  Handler  Write  Complete;
Handler[_,_,hit] = ;
Handler[_,_,_] = ReadFromDisk  Compress  StoreInCache;
atomic CheckCache:   {cacheLock};
atomic StoreInCache: {cacheLock};
atomic Complete:     {cacheLock};
handle error ReadInFromDisk  FourOhFour;
    Concise, readable expression of server logic


        No threads, etc.: simplifies programming, debugging
    

     image                                                             hit
                                                                             handler
     server                             ReadRequest        CheckCache                   Write    Complete
                     Listen
                                      handler
                                                                                          StoreInCache
                                                      ReadInFromDisk         Compress




                UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
Flux Outline

     Intro to Flux: building a server
 

         Components, flow
     

         Atomicity, deadlock avoidance
     

     Performance results
 

         Server performance
     

         Performance prediction
     

     Future work
 




         UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
Flux Results

        Four servers:
    
            Image server (+ libjpeg) [23 lines of Flux]
        

            Multi-player online game [54]
        

            BitTorrent (2 undergrads: 1 week!) [84]
        

            Web server (+ PHP) [36]
        


        Evaluation
    
            Benchmark: variant of SPECweb99
        

            Three different runtimes here
        

                 Thread:                  one per connection
             

                 Thread pool:             fixed max # threads
             

                 Event-driven:            helper threads for blocking calls
             


            Compared to Capriccio [SOSP03], SEDA [SOSP01]
        


            UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   38
Web Server




      UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   39
Performance Prediction




 observed
parameters




             UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   40
Performance Prediction




 observed
parameters




             UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   41
The End




  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   42

Contenu connexe

En vedette

Chapter3 general principles of discrete event simulation
Chapter3   general principles of discrete event simulationChapter3   general principles of discrete event simulation
Chapter3 general principles of discrete event simulation
De La Salle University-Manila
 
More Stochastic Simulation Examples
More Stochastic Simulation ExamplesMore Stochastic Simulation Examples
More Stochastic Simulation Examples
Stephen Gilmore
 
Discrete And Continuous Simulation
Discrete And Continuous SimulationDiscrete And Continuous Simulation
Discrete And Continuous Simulation
Nguyen Chien
 
Elements Of Stochastic Processes
Elements Of Stochastic ProcessesElements Of Stochastic Processes
Elements Of Stochastic Processes
MALAKI12003
 
Introduction to Discrete-Event Simulation Using SimPy
Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy
Introduction to Discrete-Event Simulation Using SimPy
pycontw
 

En vedette (20)

14 queuing
14 queuing14 queuing
14 queuing
 
Types of operating system
Types of operating systemTypes of operating system
Types of operating system
 
Queuing analysis
Queuing analysisQueuing analysis
Queuing analysis
 
Guide to Queuing System
Guide to Queuing SystemGuide to Queuing System
Guide to Queuing System
 
Chapter1
Chapter1Chapter1
Chapter1
 
Unit 6 input modeling problems
Unit 6 input modeling problemsUnit 6 input modeling problems
Unit 6 input modeling problems
 
Unit 1 introduction contd
Unit 1 introduction contdUnit 1 introduction contd
Unit 1 introduction contd
 
Chapter3 general principles of discrete event simulation
Chapter3   general principles of discrete event simulationChapter3   general principles of discrete event simulation
Chapter3 general principles of discrete event simulation
 
Extend sim 01
Extend sim 01Extend sim 01
Extend sim 01
 
More Stochastic Simulation Examples
More Stochastic Simulation ExamplesMore Stochastic Simulation Examples
More Stochastic Simulation Examples
 
Queuing theory and simulation (MSOR)
Queuing theory and simulation (MSOR)Queuing theory and simulation (MSOR)
Queuing theory and simulation (MSOR)
 
Discrete And Continuous Simulation
Discrete And Continuous SimulationDiscrete And Continuous Simulation
Discrete And Continuous Simulation
 
New Method for Simulation Of Fractures
New Method for Simulation Of FracturesNew Method for Simulation Of Fractures
New Method for Simulation Of Fractures
 
Elements Of Stochastic Processes
Elements Of Stochastic ProcessesElements Of Stochastic Processes
Elements Of Stochastic Processes
 
Unit 4 queuing models
Unit 4 queuing modelsUnit 4 queuing models
Unit 4 queuing models
 
4 stochastic processes
4 stochastic processes4 stochastic processes
4 stochastic processes
 
Stochastic modelling and its applications
Stochastic modelling and its applicationsStochastic modelling and its applications
Stochastic modelling and its applications
 
Introduction to Discrete-Event Simulation Using SimPy
Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy
Introduction to Discrete-Event Simulation Using SimPy
 
Simulation
SimulationSimulation
Simulation
 
basics of stochastic and queueing theory
basics of stochastic and queueing theorybasics of stochastic and queueing theory
basics of stochastic and queueing theory
 

Similaire à Operating Systems - Queuing Systems

Giorgio Natilli - Blaze DS Connectivity Framework
Giorgio Natilli - Blaze DS Connectivity FrameworkGiorgio Natilli - Blaze DS Connectivity Framework
Giorgio Natilli - Blaze DS Connectivity Framework
360|Conferences
 
Practical Thin Server Architecture With Dojo Peter Svensson
Practical Thin Server Architecture With Dojo Peter SvenssonPractical Thin Server Architecture With Dojo Peter Svensson
Practical Thin Server Architecture With Dojo Peter Svensson
rajivmordani
 

Similaire à Operating Systems - Queuing Systems (20)

Processes and Threads
Processes and ThreadsProcesses and Threads
Processes and Threads
 
Operating Systems - Virtual Memory
Operating Systems - Virtual MemoryOperating Systems - Virtual Memory
Operating Systems - Virtual Memory
 
Memory Management for High-Performance Applications
Memory Management for High-Performance ApplicationsMemory Management for High-Performance Applications
Memory Management for High-Performance Applications
 
Asynchronous Javascript and Rich Internet Aplications
Asynchronous Javascript and Rich Internet AplicationsAsynchronous Javascript and Rich Internet Aplications
Asynchronous Javascript and Rich Internet Aplications
 
Reliability and clock synchronization
Reliability and clock synchronizationReliability and clock synchronization
Reliability and clock synchronization
 
Lightweight Grids With Terracotta
Lightweight Grids With TerracottaLightweight Grids With Terracotta
Lightweight Grids With Terracotta
 
Web 2.0 Expo Notes
Web 2.0 Expo NotesWeb 2.0 Expo Notes
Web 2.0 Expo Notes
 
“Practical DNN Quantization Techniques and Tools,” a Presentation from Facebook
“Practical DNN Quantization Techniques and Tools,” a Presentation from Facebook“Practical DNN Quantization Techniques and Tools,” a Presentation from Facebook
“Practical DNN Quantization Techniques and Tools,” a Presentation from Facebook
 
Netcetera Proactive Management Service
Netcetera Proactive Management ServiceNetcetera Proactive Management Service
Netcetera Proactive Management Service
 
Interpreting Performance Test Results
Interpreting Performance Test ResultsInterpreting Performance Test Results
Interpreting Performance Test Results
 
Comet: an Overview and a New Solution Called Jabbify
Comet: an Overview and a New Solution Called JabbifyComet: an Overview and a New Solution Called Jabbify
Comet: an Overview and a New Solution Called Jabbify
 
The Current State of Asynchronous Processing With Ruby
The Current State of Asynchronous Processing With RubyThe Current State of Asynchronous Processing With Ruby
The Current State of Asynchronous Processing With Ruby
 
Smallsat 2021
Smallsat 2021Smallsat 2021
Smallsat 2021
 
XS 2008 Boston Capacity Planning
XS 2008 Boston Capacity PlanningXS 2008 Boston Capacity Planning
XS 2008 Boston Capacity Planning
 
Giorgio Natilli - Blaze DS Connectivity Framework
Giorgio Natilli - Blaze DS Connectivity FrameworkGiorgio Natilli - Blaze DS Connectivity Framework
Giorgio Natilli - Blaze DS Connectivity Framework
 
saurabh soni rac
saurabh soni racsaurabh soni rac
saurabh soni rac
 
Rest Vs Soap Yawn2289
Rest Vs Soap Yawn2289Rest Vs Soap Yawn2289
Rest Vs Soap Yawn2289
 
Practical Thin Server Architecture With Dojo Peter Svensson
Practical Thin Server Architecture With Dojo Peter SvenssonPractical Thin Server Architecture With Dojo Peter Svensson
Practical Thin Server Architecture With Dojo Peter Svensson
 
Services Oriented Infrastructure in a Web2.0 World
Services Oriented Infrastructure in a Web2.0 WorldServices Oriented Infrastructure in a Web2.0 World
Services Oriented Infrastructure in a Web2.0 World
 
2014 IEEE JAVA CLOUD COMPUTING PROJECT Adaptive algorithm for minimizing clou...
2014 IEEE JAVA CLOUD COMPUTING PROJECT Adaptive algorithm for minimizing clou...2014 IEEE JAVA CLOUD COMPUTING PROJECT Adaptive algorithm for minimizing clou...
2014 IEEE JAVA CLOUD COMPUTING PROJECT Adaptive algorithm for minimizing clou...
 

Plus de Emery Berger

Dthreads: Efficient Deterministic Multithreading
Dthreads: Efficient Deterministic MultithreadingDthreads: Efficient Deterministic Multithreading
Dthreads: Efficient Deterministic Multithreading
Emery Berger
 
Programming with People
Programming with PeopleProgramming with People
Programming with People
Emery Berger
 
Stabilizer: Statistically Sound Performance Evaluation
Stabilizer: Statistically Sound Performance EvaluationStabilizer: Statistically Sound Performance Evaluation
Stabilizer: Statistically Sound Performance Evaluation
Emery Berger
 
Operating Systems - Advanced File Systems
Operating Systems - Advanced File SystemsOperating Systems - Advanced File Systems
Operating Systems - Advanced File Systems
Emery Berger
 
Operating Systems - Advanced Synchronization
Operating Systems - Advanced SynchronizationOperating Systems - Advanced Synchronization
Operating Systems - Advanced Synchronization
Emery Berger
 
Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...
Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...
Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...
Emery Berger
 

Plus de Emery Berger (20)

Doppio: Breaking the Browser Language Barrier
Doppio: Breaking the Browser Language BarrierDoppio: Breaking the Browser Language Barrier
Doppio: Breaking the Browser Language Barrier
 
Dthreads: Efficient Deterministic Multithreading
Dthreads: Efficient Deterministic MultithreadingDthreads: Efficient Deterministic Multithreading
Dthreads: Efficient Deterministic Multithreading
 
Programming with People
Programming with PeopleProgramming with People
Programming with People
 
Stabilizer: Statistically Sound Performance Evaluation
Stabilizer: Statistically Sound Performance EvaluationStabilizer: Statistically Sound Performance Evaluation
Stabilizer: Statistically Sound Performance Evaluation
 
DieHarder (CCS 2010, WOOT 2011)
DieHarder (CCS 2010, WOOT 2011)DieHarder (CCS 2010, WOOT 2011)
DieHarder (CCS 2010, WOOT 2011)
 
Operating Systems - Advanced File Systems
Operating Systems - Advanced File SystemsOperating Systems - Advanced File Systems
Operating Systems - Advanced File Systems
 
Operating Systems - File Systems
Operating Systems - File SystemsOperating Systems - File Systems
Operating Systems - File Systems
 
Operating Systems - Advanced Synchronization
Operating Systems - Advanced SynchronizationOperating Systems - Advanced Synchronization
Operating Systems - Advanced Synchronization
 
Operating Systems - Synchronization
Operating Systems - SynchronizationOperating Systems - Synchronization
Operating Systems - Synchronization
 
Virtual Memory and Paging
Virtual Memory and PagingVirtual Memory and Paging
Virtual Memory and Paging
 
MC2: High-Performance Garbage Collection for Memory-Constrained Environments
MC2: High-Performance Garbage Collection for Memory-Constrained EnvironmentsMC2: High-Performance Garbage Collection for Memory-Constrained Environments
MC2: High-Performance Garbage Collection for Memory-Constrained Environments
 
Vam: A Locality-Improving Dynamic Memory Allocator
Vam: A Locality-Improving Dynamic Memory AllocatorVam: A Locality-Improving Dynamic Memory Allocator
Vam: A Locality-Improving Dynamic Memory Allocator
 
Quantifying the Performance of Garbage Collection vs. Explicit Memory Management
Quantifying the Performance of Garbage Collection vs. Explicit Memory ManagementQuantifying the Performance of Garbage Collection vs. Explicit Memory Management
Quantifying the Performance of Garbage Collection vs. Explicit Memory Management
 
Garbage Collection without Paging
Garbage Collection without PagingGarbage Collection without Paging
Garbage Collection without Paging
 
DieHard: Probabilistic Memory Safety for Unsafe Languages
DieHard: Probabilistic Memory Safety for Unsafe LanguagesDieHard: Probabilistic Memory Safety for Unsafe Languages
DieHard: Probabilistic Memory Safety for Unsafe Languages
 
Exterminator: Automatically Correcting Memory Errors with High Probability
Exterminator: Automatically Correcting Memory Errors with High ProbabilityExterminator: Automatically Correcting Memory Errors with High Probability
Exterminator: Automatically Correcting Memory Errors with High Probability
 
Operating Systems - Garbage Collection
Operating Systems - Garbage CollectionOperating Systems - Garbage Collection
Operating Systems - Garbage Collection
 
Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...
Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...
Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...
 
Composing High-Performance Memory Allocators with Heap Layers
Composing High-Performance Memory Allocators with Heap LayersComposing High-Performance Memory Allocators with Heap Layers
Composing High-Performance Memory Allocators with Heap Layers
 
Reconsidering Custom Memory Allocation
Reconsidering Custom Memory AllocationReconsidering Custom Memory Allocation
Reconsidering Custom Memory Allocation
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Operating Systems - Queuing Systems

  • 1. Operating Systems CMPSCI 377 Queuing Systems Emery Berger University of Massachusetts Amherst UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
  • 2. Queuing Systems & Servers Queuing systems  High-level model of concurrent applications  Flux  Language for building servers  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 2
  • 3. Queuing Networks Model of tasks or services  Node includes queue (line) & server  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 3
  • 4. Queuing Networks Model of tasks or services  Node includes queue (line) & server  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 4
  • 5. Queuing Networks Model of tasks or services  Node includes queue (line) & server  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 5
  • 6. Queuing Networks Model of tasks or services  Node includes queue (line) & server  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 6
  • 7. Queuing Networks Model of tasks or services  Node includes queue (line) & server  arrival rate () UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 7
  • 8. Queuing Networks Model of tasks or services  Node includes queue (line) & server  waiting time UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 8
  • 9. Queuing Networks Model of tasks or services  Node includes queue (line) & server  service time UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 9
  • 10. Queuing Networks Model of tasks or services  Node includes queue (line) & server  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 10
  • 11. Stable Systems Stable queuing system:  arrival rate = departure rate UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 11
  • 12. Stable Systems Stable queuing system:  arrival rate = departure rate UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 12
  • 13. Stable Systems Stable queuing system:  arrival rate = departure rate UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 13
  • 14. Stable Systems Stable queuing system:  arrival rate = departure rate What happens if  > departure rate?  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 14
  • 15. Stable Systems Stable queuing system:  arrival rate = departure rate What happens if  > departure rate?  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 15
  • 16. Stable Systems Stable queuing system:  arrival rate = departure rate What happens if  > departure rate?  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 16
  • 17. Stable Systems Stable queuing system:  arrival rate = departure rate What happens if  > departure rate?  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 17
  • 18. Networks of Queues Can build system from connected servers  Latency = time for one thing to get through  Throughput = service rate  5/sec 5/sec 5/sec Throughput?  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 18
  • 19. Networks of Queues Can build system with numerous  connected servers Latency = time for one thing to get through  Throughput = service rate  5/sec 1/sec 5/sec Throughput?  Lowest throughput = bottleneck  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 19
  • 20. Little’s Law Little’s Law – applies to any “blackbox”  server Queue length (N) =  arrival rate () * average waiting time (T) N=T  N  T UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 20
  • 21. Applications of Little’s Law Compute waiting time to get into  restaurant, bar, etc. If N = 20 people in front of you,   = departure rate = 1 / 5 min., how long will you wait in line? N=T N  T UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 21
  • 22. Applications of Little’s Law Required service time?  Arrival rate = one job @ 500 ms  Average queue length = 10  T=?  What’s the average latency?  N=T N  T UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 22
  • 23. Applications of Little’s Law Required service time?  Arrival rate = one job @ 500 ms  Average queue length = 5  T=?  What’s the average latency?  N=T N  T UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 23
  • 24. Motivating Example: Image Server image server Client  Requests image @ desired  quality, size not found Server  Images: RAW  http://server/Easter-bunny/ 200x100/75 Compresses to JPG  Caches requests  Sends to client  client UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
  • 25. Problem: Concurrency image Could write sequential code server  but… More clients (latency)  Bigger server  Multicores, multiprocessors  One approach: threads  Limit reuse,  risk deadlock, burden programmer Complicate debugging  Mixes program logic &  concurrency control clients UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
  • 26. The Flux Programming Language High-performance & deadlock-free concurrent programming w/ sequential components Flux = Components + Flow + Atomicity  Components unmodified C, C++ (or Java)  Flow implicitly || path thru components  Atomicity high-level mutual exclusion  Compiler generates:  Deadlock-free, runtime-independent server  Threads, thread pools, events, …  Path profiling  Discrete event simulator  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
  • 27. Flux Outline Intro to Flux: building a server  Components  Flows  Atomicity  Performance results  Server performance  Performance prediction (QNMs)  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
  • 28. Flux Server “Main” Source nodes originate flows  Conceptually in separate thread  Executes inside implicit infinite loop  Here: initiates flow for each image request  source Listen  Image; Listen image server ReadRequest Compress Write Complete ReadRequest Compress Write Complete ReadRequest Compress Write Complete UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
  • 29. Flux Image Server Basic image server requires:  HTTP parsing (http)   Socket handling (socket)  JPEG compression (libjpeg)  All UNIX-style C libraries Abstract node = flow across nodes  Concrete or abstract  Image = ReadRequest  Compress  Write  Complete; image server ReadRequest Compress Write Complete http libjpeg socket http UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
  • 30. Control Flow Direct flow via user-supplied predicate types  Type test applied to output  Note: no variables – dispatch on output “type”  Here: cache frequently requested images  typedef hit TestInCache; Handler:[_,_,hit] = ; Handler:[_,_,_] = ReadFromDisk  Compress  StoreInCache; hit handler ReadRequest CheckCache Write Complete Listen handler StoreInCache ReadInFromDisk Compress UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
  • 31. Supporting Concurrency Many clients = concurrent flows  Must keep cache consistent  Atomicity constraints  Same name = mutual exclusion  Apply to nodes or whole flow (abstract node)  atomic CheckCache {}; {, }; atomic Complete atomic StoreInCache {}; CheckCache hit ReadRequest Write Complete CheckCache hit hit ReadRequest Write Complete CheckCache hit Writehandler ReadRequest Complete Listen ReadInFromDisk Compress StoreInCache ReadRequest CheckCache StoreInCache Write Complete ReadInFromDisk Compress ReadInFromDisk Compress StoreInCache handler StoreInCache ReadInFromDisk Compress UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
  • 32. More Atomicity Reader / writer constraints  Multiple readers or single writer (default)  atomic ReadList: {listAccess?}; atomic AddToList: {listAccess!}; Per-session constraints  User-supplied function ≈ hash on source  Added to flow ≈ chooses from array of locks  atomic AddHasChunk: {chunks(session)}; UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
  • 33. Preventing Deadlock Naïve execution can deadlock  atomic A: {z,y}; atomic A: {y,z}; atomic B: {y,z}; atomic B: {y,z}; Establish canonical lock order  Partial order  Alphabetic by name  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 33
  • 34. Preventing Deadlock, II Harder with abstract nodes  A = B; C = D; A:{z} A A{z} atomic A{z}; C{y} C B atomic B{y}; atomic C{y,z}; Solution: Elevate constraints; fixed point  A = B; C = D; A{y,z} C atomic A{y,z}; B atomic B{y}; atomic C{y,z}; UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 34
  • 35. Handling Errors What if image requested doesn’t exist?  Error = negative return value from component  Remember – nodes oblivious to Flux  Solution: error handlers  Go to alternate paths on error  Possible extension – can match on error paths  handle error ReadInFromDisk  FourOhFour; hit handler ReadRequest CheckCache Write Complete Listen handler StoreInCache ReadInFromDisk Compress FourOhFour UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
  • 36. Almost Complete Flux Image Server source Listen  Image; Image = ReadRequest  CheckCache  Handler  Write  Complete; Handler[_,_,hit] = ; Handler[_,_,_] = ReadFromDisk  Compress  StoreInCache; atomic CheckCache: {cacheLock}; atomic StoreInCache: {cacheLock}; atomic Complete: {cacheLock}; handle error ReadInFromDisk  FourOhFour; Concise, readable expression of server logic  No threads, etc.: simplifies programming, debugging  image hit handler server ReadRequest CheckCache Write Complete Listen handler StoreInCache ReadInFromDisk Compress UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
  • 37. Flux Outline Intro to Flux: building a server  Components, flow  Atomicity, deadlock avoidance  Performance results  Server performance  Performance prediction  Future work  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
  • 38. Flux Results Four servers:  Image server (+ libjpeg) [23 lines of Flux]  Multi-player online game [54]  BitTorrent (2 undergrads: 1 week!) [84]  Web server (+ PHP) [36]  Evaluation  Benchmark: variant of SPECweb99  Three different runtimes here  Thread: one per connection  Thread pool: fixed max # threads  Event-driven: helper threads for blocking calls  Compared to Capriccio [SOSP03], SEDA [SOSP01]  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 38
  • 39. Web Server UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 39
  • 40. Performance Prediction observed parameters UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 40
  • 41. Performance Prediction observed parameters UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 41
  • 42. The End UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 42