TOWARDS TRANSPARENT CPU SCHEDULING by Joseph T
Total Page:16
File Type:pdf, Size:1020Kb
TOWARDS TRANSPARENT CPU SCHEDULING by Joseph T. Meehean A dissertation submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy (Computer Sciences) at the UNIVERSITY OF WISCONSIN–MADISON 2011 © Copyright by Joseph T. Meehean 2011 All Rights Reserved i ii To Heather for being my best friend Joe Passamani for showing me what’s important Rick and Mindy for reminding me Annie and Nate for taking me out Greg and Ila for driving me home Acknowledgments Nothing of me is original. I am the combined effort of everybody I’ve ever known. — Chuck Palahniuk (Invisible Monsters) My committee has been indispensable. Their comments have been enlight- ening and valuable. I would especially like to thank Andrea for meeting with me every week whether I had anything worth talking about or not. Her insights and guidance were instrumental. She immediately recognized the problems we were seeing as originating from the CPU scheduler; I was incredulous. My wife was a great source of support during the creation of this work. In the beginning, it was her and I against the world, and my success is a reflection of our teamwork. Without her I would be like a stray dog: dirty, hungry, and asleep in afternoon. I would also like to thank my family for providing a constant reminder of the truly important things in life. They kept faith that my PhD madness would pass without pressuring me to quit or sandbag. I will do my best to live up to their love and trust. The thing I will miss most about leaving graduate school is the people. My support network of friends has been vast over my many years in graduate school. In particular, I would like to thank Nate and Annie for their incredible iii generosity and for being so damn fun in general. Together they created a center around which we built our Madison family. I would also like to thank Greg and Ila for their steadfast loyalty. I know that wherever I am and whatever my problem they will not hesitate to help. Trevor provided a constant reminder that I was full of hot air, but never failed to help me generate more. Rush made me laugh in unexpected and often absurd ways. Special thanks to the Condor Team, in particular Ken Hahn, Steve Barnet, Todd Miller, Greg Thain and Doug Thain. I would also like to thank the ADSL group, especially Swami Sundararaman, Leo Arulraj, Haryadi Gunawi, and Nitin Agrawal. This work was funded by the NSF under a variety of grants. iv Contents Contents v List of Tables ix List of Figures xi Abstract xv 1 Introduction 1 1.1 Importance of CPU Scheduling ..................... 2 1.2 Opaque CPU Schedulers ........................ 4 1.3 Increasing Transparency of CPU Scheduling .............. 5 1.4 Organization .............................. 7 I CPU Scheduling Background 9 2 CPU Scheduling 11 2.1 Environment .............................. 12 2.2 CPU Scheduling ............................ 14 2.3 Multiprocessor Scheduling ....................... 20 v 2.4 Commodity Schedulers ......................... 25 2.5 Summary ................................ 29 3 Opaque CPU Scheduling 33 3.1 CPU Contention ............................ 34 3.2 Application CPU Contention Policies . 35 3.3 Barriers to Good Scheduling ...................... 36 3.4 Limited Scheduling Interface ...................... 38 3.5 Unpredictability of Best Effort Schedulers . 43 3.6 Limited Scheduler Feedback ....................... 45 3.7 Experimental Examples ......................... 47 3.8 Commodity Approaches to Mitigate CPU Contention . 52 3.9 Summary ................................ 55 II CPU Futures 57 4 Scheduler support for application management of CPU contention 59 4.1 Requirements .............................. 61 4.2 CPU Futures .............................. 62 4.3 Scheduler-Agnostic Feedback ...................... 66 4.4 Scheduler Models ............................ 68 4.5 Implementation Details ......................... 82 4.6 Evaluation ................................ 84 4.7 Summary ................................ 94 5 CPU Futures Controller Case Studies 95 5.1 CPU Future’s Controller ........................ 97 5.2 Empathy ................................. 99 5.3 Starvation Avoidance Shepherd . 105 5.4 Fair Throughput Shepherd . 110 5.5 Summary ................................114 vi III Harmony 117 6 Uncovering CPU Load Balancing Policies with Harmony 119 6.1 Harmony ................................121 6.2 Multiprocessor Scheduling Policy Foundations . 125 6.3 How Many Processes are Migrated? . 128 6.4 Time to Resolve and Detect? . 132 6.5 Summary ................................136 7 Load Balancing Non-Fungible Processes 137 7.1 Resolution of Intrinsic Imbalances? . 138 7.2 Resolution of Mixed CPU Workloads? . 143 7.3 Resolution of Priority Classes? . 155 7.4 Discussion ...............................160 7.5 Conclusion ...............................163 IV Context and Conclusions 165 8 Related Work 167 8.1 CPU Futures ..............................167 8.2 Harmony ................................171 9 Conclusions 173 9.1 Summary ................................174 9.2 Ideal Scheduling .............................177 9.3 Lessons Learned .............................178 9.4 Hindsight ................................180 References 183 vii List of Tables 4.1 SPECint2006 overhead results . 84 4.2 Time to query herald . 84 4.3 Accuracy and precision of predicted and potential allocation metrics 93 6.1 Imbalance Detection . 135 7.1 The Load-balancing Policies Extracted by Harmony . 161 ix List of Figures 2.1 Global vs. Distributed Queues . 23 3.1 CPU allocations given an increasing system workload . 48 3.2 Break down of Apache worker throughput . 50 3.3 Break down of starving requests by cause . 52 4.1 CPU Futures architecture . 64 4.2 Desired allocation . 67 4.3 Timesharing model . 71 4.4 CPU Futures herald output . 83 4.5 The herald metrics illustration . 85 4.6 O(1) alternating priority . 86 4.7 O(1) alternating priority, detailed view . 87 4.8 O(1) alternating priority with and without modeled starvation pre- vention . 89 4.9 CFS alternating priority . 90 4.10 CFS alternating priority, detailed view . 90 4.11 CFS alternating demand . 91 4.12 O(1) alternating demand . 92 xi 5.1 Example of feedback-controller search algorithm. 97 5.2 Empathy minimal interference experiment . 100 5.3 Empathy-managed video conversion running simultaneously with increasing Apache web server workload . 103 5.4 Empathy video conversion running simultaneously with a fixed Apache web server workload . 104 5.5 Average Apache starvation counts . 107 5.6 CDF of response times for starving requests . 108 5.7 Starvation counts for a variety of workload mixes . 109 5.8 Normalized throughput for a variety of workloads . 110 5.9 Jain fairness index for a fixed MPL Apache and Shepherd . 111 5.10 CDF of the response times for starving requests . 112 5.11 Jain index for a variety of workloads . 113 6.1 O(1) Load Balancing Snippet . 123 6.2 Single-source and Single-target . 124 6.3 Timeline of Process Migrations for O(1), CFS, and BFS Schedulers . 126 6.4 Timeline of Run Queues for O(1) . 127 6.5 CPU allocations . 129 6.6 First Migration: O(1) and CFS . 131 6.7 Time to Resolve Imbalance . 133 6.8 Imbalance Detection . 135 7.1 Allocations with Intrinsic Imbalances . 139 7.2 Migration Timeline with Intrinsic Imbalances . 140 7.3 Run queue lengths for CFS with Intrinsic Imbalances . 141 7.4 Allocation Timeline for CFS with Intrinsic Imbalances . 142 7.5 Run Queue Timelines for Mixed CPU Workloads . 145 7.6 Run Queue Match . 146 7.7 Sticky Priority Bonuses in O(1) . 147 7.8 Sticky Priority Bonuses Across Migration in O(1) . 148 7.9 Losing Balance in CFS . 149 7.10 Migrations for Heavy/Light workload . 150 xii 7.11 Run Queue Match . 152 7.12 CPU Allocations for Heavy Processes with O(1), CFS, and BFS . 154 7.13 Migrations for Mixed Priorities with BFS . 156 7.14 O(1) and CFS Migrations for Mixed Priorities . 157 7.15 CPU Allocations for High Priority Processes with O(1), CFS, and BFS159 xiii Abstract In this thesis we propose using the scientific method to develop a deeper under- standing of CPU schedulers; we use this approach to explain and understand the sometimes erratic behavior of CPU schedulers. This approach begins with introducing controlled workloads into commodity operating systems and ob- serving the CPU scheduler’s behavior. From these observations we are able to infer the underlying CPU scheduling policy and create models that predict scheduling behavior. We have made two advances in the area of applying scientific analysis to CPU schedulers. The first, CPU Futures, is a combination of predictive scheduling models embedded into the CPU scheduler and user-space controller that steers applications using feedback from these models. We have developed these predictive models for two different Linux schedulers (CFS and O(1)), based on two different scheduling paradigms (timesharing and proportional-share). Using three different case studies, we demonstrate that applications can use our predictive models to reduce interference from low-importance applications by over 70%, reduce web server starvation by an order of magnitude, and enforce scheduling policies that contradict the CPU scheduler’s. Harmony, our second contribution, is a framework and set of experiments for extracting multiprocessor scheduling policy from commodity operating systems. We used this tool to extract and analyze the policies of three Linux xv Abstract schedulers: O(1), CFS, and BFS. These schedulers often implement strikingly different policies. At the high level, the O(1) scheduler carefully selects pro- cesses for migration and strongly values processor affinity. In contrast, CFS continuously searches for a better balance and, as a result, selects processes for migration at random. BFS strongly values fairness and often disregards processor affinity. xvi Chapter 1 Introduction It is a habit of mankind to entrust to careless hope what they long for, and to use sovereign reason to thrust aside what they do not desire. — Thucydides Best-effort CPU schedulers are currently regarded as a reliable black box by applications, developers, and systems researchers. These schedulers are depended upon to provide a low-level, but vital service.