The University of Chicago Abstract Trace Analysis
Total Page:16
File Type:pdf, Size:1020Kb
THE UNIVERSITY OF CHICAGO ABSTRACT TRACE ANALYSIS FOR CONCURRENT PROGRAMS A DISSERTATION SUBMITTED TO THE FACULTY OF THE DIVISION OF THE PHYSICAL SCIENCES IN CANDIDACY FOR THE DEGREE OF DOCTOR OF PHILOSOPHY DEPARTMENT OF COMPUTER SCIENCE BY YINGQI XIAO CHICAGO, ILLINOIS AUGUST 2010 To my parents, Meng and Mingying, and my wife, Jing. TABLE OF CONTENTS LIST OF FIGURES . vi ACKNOWLEDGEMENTS . viii ABSTRACT . ix Chapter 1 INTRODUCTION . 1 1.1 The Challenges . 2 1.1.1 A Simple Concurrent Language . 2 1.1.2 A Simple Example . 4 1.1.3 A Pipeline Example . 6 1.2 This Dissertation . 9 1.3 Organization of This Dissertation . 12 2 BACKGROUND AND RELATED WORK . 14 2.1 Data-Flow Analysis . 14 2.1.1 An Example: Reaching-Definition Analysis for Channels . 15 2.2 Control-Flow Analysis . 16 2.3 π-calculus . 18 2.4 Related Work . 20 2.4.1 Input and Output Only Channels . 21 2.4.2 Linear Types for Concurrent Languages . 22 2.4.3 Nielson and Nielson’s Type and Effect System . 26 2.4.4 Session Types . 29 2.4.5 Colby’s Abstract Interpretation Approach . 30 2.4.6 Our Previous Work . 31 iii 3 ABSTRACT TRACE ANALYSIS . 35 3.1 Dynamic Semantics . 35 3.1.1 Properties of Traces . 39 3.2 Abstract Trace Analysis Overview . 40 3.3 Type-Sensitive Control-Flow Analysis for CML . 41 3.3.1 Introduction of 0-CFA . 41 3.3.2 Abstract Values . 43 3.3.3 Type-Sensitive CFA . 44 3.3.4 Properties . 45 3.4 The Extended CFG . 45 3.5 Abstract Trace Analysis . 47 4 APPLICATIONS OF ANALYSIS . 51 4.1 Detecting Special Communication Pattern . 51 4.1.1 Specialized Channel Operations . 52 4.1.2 An Example . 53 4.1.3 Communication Topology Analysis . 56 4.2 Concurrency Analysis . 65 4.2.1 Overview . 66 4.2.2 Ordering Enforced by Control Flow . 67 4.2.3 Ordering Enforced by Synchronization . 71 4.2.4 Refinement . 73 4.2.5 Automatic Monitor Recognition and Transformation . 73 4.2.6 Monitor Communication Pattern Recognition . 77 4.2.7 Monitor Thread Transformation . 81 5 ANALYSIS CORRECTNESS . 84 5.1 Communication Topology . 84 5.2 Concurrency Analysis . 97 6 IMPLEMENTATION . 103 6.1 The Type-Sensitive CFA Algorithm . 103 6.2 Abstract Trace Analysis Algorithm . 108 6.3 Implementation of Specialized CML Primitives . 110 6.3.1 Preliminaries . 111 6.3.2 The General Parallel Implementation . 114 6.3.3 A Reference Implementation of Fan-In and Fan-Out Channels . 114 iv 7 PERFORMANCE . 122 7.1 One-To-One Benchmark . 123 7.2 Primes Benchmark . 124 7.3 Fan-Out and Fan-In Benchmarks . 126 7.4 Monitor Benchmark . 129 8 CONCLUSION . 132 8.1 Summary . 132 8.2 Future Work . 133 REFERENCES . 135 v LIST OF FIGURES 1.1 A simple concurrent language . 3 1.2 A simple example in SCL . 4 1.3 The flow graph of the simple example . 5 1.4 Simple pipeline . 7 1.5 The flow graph of the simple pipeline example . 8 1.6 One possible history of five processes . 10 2.1 Syntax of π-calculus . 18 2.2 Structural congruence of the π-calculus . 19 2.3 Reduction rules of the π-calculus . 19 2.4 Syntax of tagged processes . 22 2.5 Typing rules . 23 2.6 Syntax for linear type channels . 23 2.7 Reduction rules of linear types channels . 24 2.8 Typing rules . 25 2.9 Typing rules . 27 2.10 Concurrent evaluation rules . 28 2.11 Analyzing the CFG G for channel c .................... 33 3.1 Sequential evaluation . 37 3.2 The join of two abstract values . 44 3.3 Approximation of channel send and receive sites . 45 3.4 Simple service . 49 4.1 A simple service with an abstract client-server protocol . 54 4.2 Data-flow of the server’s request channel . 55 4.3 A version of Figure 4.1 with specialized communication operations . 56 4.4 Standard data-flow equations . 68 4.5 A self-concurrent example . 68 4.6 The self-concurrent example in ECFG . 69 4.7 Data-flow equations for concurrency analysis . 71 4.8 A simple example with synchronization edge . 73 4.9 The self-concurrent example in ECFG . 74 4.10 An example of monitor tasks . 75 4.11 Simple monitor . 76 4.12 The optimized version of simple monitor . 77 4.13 The simple monitor after transformation . 83 vi 5.1 The definition of abs ............................ 87 6.1 CFA for expressions Part I . 104 6.2 CFA for expressions Part II . 105 6.3 Algorithm for abstract traceflow analysis . 109 6.4 Algorithm for testing for a valid trace . 109 6.5 Algorithm for redundant trace . 110 6.6 The reference implementation of general send . 113 6.7 The reference implementation of general recv . 113 6.8 The specialized implementation of send for fan-in channels . 118 6.9 The specialized implementation of recv for fan-in channels . 119 6.10 The specialized implementation of send for fan-out channels . 120 6.11 The specialized implementation of recv for fan-out channels . 121 7.1 Primes benchmark results . 125 7.2 Primes speed-up curves . 125 7.3 Fan-out benchmark results . 126 7.4 Fan-out speed-up curves . 127 7.5 Fan-in benchmark results . 128 7.6 Fan-in speed-up curves . 128 7.7 Monitor benchmark results . 130 7.8 Monitor speed-up curves . 131 vii ACKNOWLEDGEMENTS First of all, I would like to thank my advisor, Professor John H. Reppy, for his support and guidance throughout my graduate research at the University of Chicago and for his help with the proof reading of this dissertation. Without his insight and guidance, I would never be able to accomplish this dissertation. I would also like to thank other members of my committee, Dave MacQueen and Xinyu Feng, for reading my dissertation and providing feedback on it. I would like to give my heartfelt thanks to my parents, who raised me with their endless love and support. I would also like to give my heartfelt thanks to my wife, who has accom- panied me with her love, understanding and encouragement. I dedicate this dissertation to my parents and my wife. Finally, I would like to.