640 likes | 784 Views
Dynamic Shape Analysis via Degree Metrics. Maria Jump & Kathryn S. McKinley Department of Computer Sciences The University of Texas at Austin {mjump,mckinley}@cs.utexas.edu. Software is Dynamic. Software is always changing New expectations New algorithms New applications New users
E N D
Dynamic Shape Analysisvia Degree Metrics Maria Jump & Kathryn S. McKinley Department of Computer Sciences The University of Texas at Austin {mjump,mckinley}@cs.utexas.edu
Software is Dynamic • Software is always changing • New expectations • New algorithms • New applications • New users • New notions of what is cool • Limited only by human ambition First Law of Software: Software is a gas! It expands to fit the container it is in! [Nathan Myhrvold, Former CTO, Microsoft] Jump & McKinley
Property of a system that is directly proportional to thedifficulty one has in comprehending the system at a level and detail necessary to make changes without introducing instability or functional regressions [Peter Rosser, Microsoft Software Engineer] Software Complexity • Developed by large teams • Few, if any, understand all parts • Need tools to help Jump & McKinley
Program Analysis Program= Code + Data Software complexity leads to heap complexity Jump & McKinley
Heap Complexity • Exacerbated by modern languages • Objects are smaller and more numerous • Most objects allocated on the heap • Objects encode program state • Heap contains semantic, memory, and concurrency bugs Program analysis is incompletewithout heap analysis Jump & McKinley
An Opportunity • Automatic memory management examines live data on a regular basis • Understand heap usage • Detect heap-based bugs • Optimize program based on heap usage Opportunity to performheap analysis dynamically Jump & McKinley
Shape Analysis Characterize the “shape” of heap-allocatedpointer-based data structures andverify shape-preserving properties Jump & McKinley
Shape Analysis Static • Conservatively characterizes all “possible” shapes at every program point • Only works on small programs Dynamic • Discover shape of current data structure • Generate assertionsfor verification • Monitor shape duringentire execution Program= Code + Data Jump & McKinley
Shape Analysis Library Custom LinkedHashMap: 99.3% % of Heap BinaryTree: 35.8% HashMap: 59.5% OctTree: 98% Custom: 33% Library: 58% Jump & McKinley
ShapeUp • Desired goals • Discover shape of current data structure • Discover dynamic invariants • Monitor expected shape of current data structure during execution • Heap summarization graph[POPL ‘07] • Class field-wise graph (CFWG) • Identifies recursive data structures (RDS) • Summarize dynamic degree invariants Jump & McKinley
Class Field-Wise Graph (CFWG) Heap CFWG Home-brewed data structure from SPECjbb2000 (simplified) Jump & McKinley
Class Field-Wise Graph (CFWG) Heap CFWG Home-brewed data structure from SPECjbb2000 (simplified) Jump & McKinley
Class Field-Wise Graph (CFWG) Heap CFWG Degree Metrics Home-brewed data structure from SPECjbb2000 (simplified) Jump & McKinley
Degree Metrics • Degree metrics per instance: • Out-degree: # of outgoing references • In-degree: # of incoming references • Only count edges between objectsof same class • Use word in header to track in-degree of backbone objects • Summarize by class per data structure instance in a degree profile Jump & McKinley
CFWG Calculating Degree Profile Jump & McKinley
CFWG Calculating Degree Profile Jump & McKinley
CFWG Calculating Degree Profile Jump & McKinley
CFWG Calculating Degree Profile n=1 Jump & McKinley
CFWG Calculating Degree Profile n=1 Jump & McKinley
CFWG Calculating Degree Profile n=1 Jump & McKinley
CFWG Calculating Degree Profile n=2 Jump & McKinley
CFWG Calculating Degree Profile n=2 Jump & McKinley
CFWG Calculating Degree Profile n=2 Jump & McKinley
CFWG Calculating Degree Profile n=3 Jump & McKinley
CFWG Calculating Degree Profile n=3 Jump & McKinley
CFWG Calculating Degree Profile n=3 Jump & McKinley
CFWG Calculating Degree Profile n=4 Jump & McKinley
CFWG Calculating Degree Profile n=5 Jump & McKinley
CFWG Calculating Degree Profile n=6 Jump & McKinley
CFWG Calculating Degree Profile n=6 Jump & McKinley
CFWG Calculating Degree Profile n=6 Jump & McKinley
CFWG Calculating Degree Profile n=7 Jump & McKinley
CFWG Calculating Degree Profile n=8 Jump & McKinley
CFWG Calculating Degree Profile n=9 Jump & McKinley
CFWG Calculating Degree Profile n=9 Jump & McKinley
CFWG Calculating Degree Profile n=9 Jump & McKinley
CFWG Calculating Degree Profile n=10 Jump & McKinley
CFWG Calculating Degree Profile n=10 Jump & McKinley
CFWG Calculating Degree Profile n=10 Jump & McKinley
CFWG Calculating Degree Profile n=11 Jump & McKinley
CFWG Calculating Degree Profile n=12 Jump & McKinley
CFWG Calculating Degree Profile n=13 Jump & McKinley
CFWG Calculating Degree Profile n=13 Jump & McKinley
CFWG Calculating Degree Profile n=13 Jump & McKinley
CFWG Calculating Degree Profile n=14 Jump & McKinley
Calculating Degree Profile n=15 CFWG Jump & McKinley
Calculating Degree Profile constant n CFWG range Complete Binary Tree Jump & McKinley
CFWG Calculating Degree Profile constant range left right Complete Binary Tree Jump & McKinley
Interpreting Degree Profile • Monitoring degree profile shows errors: • Error: constant violation • Warning: range violation [min-,max+] • Indicate problem with RDS during development and testing • Monitor shape after deployment for dynamically introduced errors What kind of errors can be detected? Jump & McKinley
Implementation and Methodology • Jikes RVM • SPECjvm98, DaCapo, SPECjbb2000 • Heap composition • Showed degree metric are stable by class • Overheads • <8% total time • <1% space overhead [used bits in header] • Microbenchmarks • Single RDS in isolation • Random error injection Singly-linked list Doubly-linked list Binary Tree Binary Tree w/ PP Jump & McKinley