1 / 50

Online Subpath Profiling

Online Subpath Profiling. Yossi Matias David Oren Mooly Sagiv School of Computer Science Tel-Aviv University. Motivation for Profiling. Feedback on dynamic program behavior The 80-20 rule Can be used by: Computer Architects Compiler Writers Programmers Better program performance.

Download Presentation

Online Subpath Profiling

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Online Subpath Profiling Yossi Matias David Oren Mooly Sagiv School of Computer Science Tel-Aviv University

  2. Motivation for Profiling • Feedback on dynamic program behavior • The 80-20 rule • Can be used by: • Computer Architects • Compiler Writers • Programmers • Better program performance

  3. Types of Profiling • Vertex profiling • No context, just count of instructions • Edge profiling • Branch-transition • Profile-directed optimization • Path profiling • Multiple branch-transition • Intra- or inter-procedural

  4. Types of Profiling • Offline • Results are collected and then displayed • User in the loop • Online • Results are collected and acted upon • JIT compilation • Display to user

  5. if (condition1) doA () doB () doCommon () doMore () if (condition2) doC () doD () Motivation for Subpath Profiling • Programs may have hot subpaths • which are part of cold paths

  6. Challenges • Large number of subpaths • >4M distinct subpaths of length 2,4,...,64k in JLex • >35M total subpaths • Counting all subpaths is prohibitively expensive • Memory • Time • non linear

  7. Online Subpath Profiler • Based on an adaptive sampling technique • Identifies arbitrary hot subpaths • Low memory overhead • Low runtime overhead • Online • Appropriate for JIT-like compilers • Can be adapted to different requirements

  8. Outline • Algorithm overview • Adaptive sampling • Issues • The OSP algorithm • Reference implementation • Experimental results • Related work • Conclusion

  9. Algorithm Overview • Select on-the-fly a random sample of subpaths • Count the popularity of sampled subpaths and obtain estimation by scaling • Achieve high accuracy using limited memory

  10. Adaptive Sampling • Based on a hot-list algorithm by Gibbons and Matias (SIGMOD 1998) • Sample elements from the input set • Frequently occurring elements will be sampled more often • Sampling probability determined at runtime, according to the allowed memory usage • Tradeoff between overhead and accuracy • Give an estimate of the sample’s accuracy

  11. Concise Samples • Uniform random sampling • Maintain an <id, count> pair for each element • The sample size can be much larger than the memory size • For skewed input sets the gain is much larger • Sampling is not applied at every block • Vitter’s reservoir sampling

  12. Concise Samples

  13. Issues • Encoding • Generating a unique ID for paths • Path length bias • Longer or shorter paths? • Path representation

  14. Sampled path Sampled path Basic blocks skipped Basic blocks skipped The OSP Algorithm void enterBlock (BasicBlock b) { if (sampling) sampleBlock (b); else if (--skip == 0) { length = choosePathLength (); sampling = true; } } void sampleBlock (BasicBlock b) { subpath.appendBlock (b); if (--length == 0) { updateHotList (subpath.id); skip = chooseSkipValue (); subpath = new subPath (); sampling = false; } }

  15. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 5 sampling = false void enterBlock (BasicBlock b) { if (sampling) sampleBlock (b); else if (--skip == 0) { length = choosePathLength (); sampling = true; } } Skipping Sampling

  16. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 4 sampling = false Skipping Sampling

  17. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 3 sampling = false Skipping Sampling

  18. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 2 sampling = false Skipping Sampling

  19. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 1 sampling = false Skipping Sampling

  20. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 0 length = 2 sampling = true void enterBlock (BasicBlock b) { if (sampling) sampleBlock (b); else if (--skip == 0) { length = choosePathLength (); sampling = true; } } Skipping Sampling

  21. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 0 length = 1 sampling = true Skipping Sampling

  22. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 4 length = 0 sampling = false doA-doCommon: 1 void sampleBlock (BasicBlock b) { subpath.appendBlock (b); if (--length == 0) { updateHotList (subpath.id); skip = chooseSkipValue (); subpath = new subPath (); sampling = false; } } Skipping Sampling

  23. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 3 sampling = false doA-doCommon: 1 Skipping Sampling

  24. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 2 sampling = false doA-doCommon: 1 Skipping Sampling

  25. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 1 sampling = false doA-doCommon: 1 Skipping Sampling

  26. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 0 length = 2 sampling = true doA-doCommon: 1 Skipping Sampling

  27. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 0 length = 1 sampling = true doA-doCommon: 1 Skipping Sampling

  28. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 8 sampling = false doA-doCommon: 1 doCommon-if2: 1 Skipping Sampling

  29. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 7 sampling = false doA-doCommon: 1 doCommon-if2: 1 Skipping Sampling

  30. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 6 sampling = false doA-doCommon: 1 doCommon-if2: 1 Skipping Sampling

  31. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 5 sampling = false doA-doCommon: 1 doCommon-if2: 1 Skipping Sampling

  32. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 4 sampling = false doA-doCommon: 1 doCommon-if2: 1 Skipping Sampling

  33. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 3 sampling = false doA-doCommon: 1 doCommon-if2: 1 Skipping Sampling

  34. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 2 sampling = false doA-doCommon: 1 doCommon-if2: 1 Skipping Sampling

  35. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 1 sampling = false doA-doCommon: 1 doCommon-if2: 1 Skipping Sampling

  36. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 0 length = 2 sampling = true doA-doCommon: 1 doCommon-if2: 1 Skipping Sampling

  37. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 0 length = 1 sampling = true doA-doCommon: 1 doCommon-if2: 1 Skipping Sampling

  38. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () OSP Algorithm Walkthrough skip = 6 sampling = false doA-doCommon: 1 doCommon-if2: 2 Skipping Sampling

  39. if (condition1) doA () doB () doCommon () if (condition2) doC () doD () After 1000 Iterations doCommon-if2: 253 If1-doA: 130 If2-doD: 127 if1-doB: 122 if2-doC: 118 if1-doA-..-if2: 65 …

  40. Prototype Implementation • Written in Java, using the Soot Framework • Handles full Java • Low memory overhead (~50kB) • Low sampling overhead (5%-50%) • Sampling + Skipping overhead (current implementation): 30%-360% • High accuracy on tested benchmarks

  41. Prototype Implementation • Limited to paths of length 2n • Favorable tradeoff • Simple encoding • Tested for practical performance • Gives more weight to shorter paths • Only implementation details!

  42. Results – Runtime Overhead

  43. Results – Memory Overhead

  44. Results – Accuracy (FFT)

  45. Results – Incremental (FFT)

  46. Related Work • Ball, Larus: Efficient path profiling (MICRO 1996) • Larus: Whole program paths (PLDI 1999) • Melski, Reps: Interprocedural path profiling (CC 1999) • Taub, Schechter, Smith: Ephemeral instrumentation for lightweight program profiling (2000) • Sastry, Bodik, Smith: Rapid profiling via stratified sampling (Computer Architecture 2001) • Bala, Duesterwald, Banerjia: Dynamo: a transparent dynamic optimization system (PLDI 2001)

  47. Related Work • Ball-Larus path profiler (MICRO 1996) and extensions • Only Acyclic paths • Whole Program Path (Larus, PLDI 1999) • Uses an alphabet representing acyclic paths • Compact image of a whole program trace • Not online

  48. Related Work • Dynamo (PLDI 2000) • A dynamic compiler for native code • Locates “hot traces” and optimizes them • Limits places where hot traces may start • It would be interesting to integrate OSP into Dynamo

  49. Limitations • Results are only an approximation • Other methods are approximations as well • Guaranteed confidence and accuracy as function of hotness • Context not taken into account • Robust, works for arbitrary subpaths • Stand alone tool • Integrate into existing tools

  50. Conclusions • We have presented a framework for online subpath profiling • We have a reference implementation • Simple • Efficient • Accurate

More Related