SlideShare a Scribd company logo
1 of 27
Estimating Path Execution Frequency StaticallyRay Buse
Wes Weimer
THE ROAD NOT TAKENICSE 2009
Vancouver, BC
2
The Big Idea
 Developers often have a expectations about
common and uncommon cases in programs
 The structure of code they write can sometimes
reveal these expectations
3
Example
public V function(K k , V v)
{
if ( v == null )
throw new Exception();
if ( c == x )
r();
i = k.h();
t[i] = new E(k, v);
c++;
return v;
}
4
Example
public V function(K k , V v)
{
if ( v == null )
throw new Exception();
if ( c == x )
restructure();
i = k.h();
t[i] = new E(k, v);
c++;
return v;
}
Exception
Invocation that changes
a lot of the object state
Some
computation
5
Path 1
public V function(K k , V v)
{
if ( v == null )
throw new Exception();
if ( c == x )
restructure();
i = k.h();
t[i] = new E(k, v);
c++;
return v;
}
6
public V function(K k , V v)
{
if ( v == null )
throw new Exception();
if ( c == x )
restructure();
i = k.h();
t[i] = new E(k, v);
c++;
return v;
}
Path 2
7
Path 3
public V function(K k , V v)
{
if ( v == null )
throw new Exception();
if ( c == x )
restructure();
i = k.h();
t[i] = new E(k, v);
c++;
return v;
}
8
HashTable: put
public V put(K key , V value)
{
if ( value == null )
throw new Exception();
if ( count >= threshold )
rehash();
index = key.hashCode() % length;
table[index] = new Entry(key, value);
count++;
return value;
}
*simplified from java.util.HashTable jdk6.0
9
Intuition
How a path modifies program state may correlate
with it’s runtime execution frequency
 Paths that change a lot of state are rare
 Exceptions, initialization code, recovery code etc
 Common paths tend to change a small amount
of state
Stack State +
Heap State
10
More Intuition
 Number of branches
 Number of method invocations
 Length
 Percentage of statements in a method executed
 …
11
Hypothesis
We can accurately predict the runtime frequency of
program paths by analyzing their static surface
features
Goals:
 Know what programs are likely to do without
having to run them (Produce a static profile)
 Understand the factors that are predictive of
execution frequency
12
Our Path
 Intuition
 Candidates for static profiles
 Our approach
 a descriptive model of path
frequency
 Some Experimental Results
13
Applications for Static Profiles
 Indicative (dynamic) profiles are often hard to get
Profile information can improve many analyses
 Profile guided optimization
 Complexity/Runtime estimation
 Anomaly detection
 Significance of difference between program
versions
 Prioritizing output from other static analyses
14
Approach
 Model path with a set of features that
may correlate with runtime path
frequency
 Learn from programs for which we have
indicative workloads
 Predict which paths are most or
least likely in other programs
15
Experimental Components
 Path Frequency Counter
 Input: Program, Input
 Output: List of paths + frequency count for each
 Descriptive Path Model
 Classifier
16
Our Definition of Path
 Statically enumerating full program paths doesn't
scale
 Choosing only intra-method paths doesn't give us
enough information
 Compromise: Acyclic Intra-Class Paths
 Follow execution from public method entry point until
return from class
 Don’t follow back edges
17
Experimental Components
 Path Frequency Counter
 Input: Program, Input
 Output: List of paths + frequency count for each
 Descriptive Path Model
 Input: Path
 Output: Feature Vector describing the path
 Classifier
18
Count Coverage Feature
• pointer comparisons
• new
• this
• all variables
• assignments
• dereferences
• • fields
• • fields written
• • statements in invoked method
• goto stmts
• if stmts
• local invocations
• • local variables
• non-local invocations
• • parameters
• return stmts
• statements
• throw stmts
19
Experimental Components
 Path Frequency Counter
 Input: Program, Input
 Output: List of paths + frequency count for each
 Descriptive Path Model
 Input: Path
 Output: Feature Vector describing the path
 Classifier
 Input: Feature Vector
 Output: Frequency Estimate
20
Classifier: Logistic Regression
 Learn a logistic function to estimate the
runtime frequency of a path
Likely to
be taken
Not likely to
be taken
Input path {x1, x2 … xn}
21
Model Evaluation
 Use the model to rank all static paths in the
program
 Measure how much of total program runtime is
spent:
 On the top X paths for each method
 On the top X% of all paths
 Also, compare to static branch predictors
 Cross validation on Spec JVM98 Benchmarks
 When evaluating on one, train on the others
22
Evaluation: Top Paths
Choose 5% of all
paths and get 50% of
runtime behavior
Choose 1 path per
method and get 94%
of runtime behavior
23
Evaluation: Static Branch Predictor
We are even a
reasonable choice for
static branch prediction
Branch Taken;
Forward Not Taken
A set of
heuristics
Always choose the
higher frequency path
24
Model Analysis: Feature Power
Exceptions are
predictive but rare
Many
features “tie”
Path length matters
most
More assignment
statements → lower
frequency
25
Conclusion
A formal model that statically predicts relative
dynamic path execution frequencies
A generic tool (built using that model) that takes only
the program source code (or bytecode) as input
and produces
 for each method, an ordered list of paths through that
method
The promise of helping other program analyses and
transformations
26
Questions? Comments?
27
Evaluation by Benchmark
1.0 = perfect
0.67 = return all or
return nothing

More Related Content

What's hot

Automatically Generated Patches as Debugging Aids: A Human Study (FSE 2014)
Automatically Generated Patches as Debugging Aids: A Human Study (FSE 2014)Automatically Generated Patches as Debugging Aids: A Human Study (FSE 2014)
Automatically Generated Patches as Debugging Aids: A Human Study (FSE 2014)
Sung Kim
 
REMI: Defect Prediction for Efficient API Testing (

ESEC/FSE 2015, Industria...
REMI: Defect Prediction for Efficient API Testing (

ESEC/FSE 2015, Industria...REMI: Defect Prediction for Efficient API Testing (

ESEC/FSE 2015, Industria...
REMI: Defect Prediction for Efficient API Testing (

ESEC/FSE 2015, Industria...
Sung Kim
 

What's hot (20)

Dissertation Defense
Dissertation DefenseDissertation Defense
Dissertation Defense
 
Path Testing
Path TestingPath Testing
Path Testing
 
Path testing
Path testingPath testing
Path testing
 
10 software testing_technique
10 software testing_technique10 software testing_technique
10 software testing_technique
 
Automatically Generated Patches as Debugging Aids: A Human Study (FSE 2014)
Automatically Generated Patches as Debugging Aids: A Human Study (FSE 2014)Automatically Generated Patches as Debugging Aids: A Human Study (FSE 2014)
Automatically Generated Patches as Debugging Aids: A Human Study (FSE 2014)
 
White Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR ChandigarhWhite Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR Chandigarh
 
Software Quality Testing
Software Quality TestingSoftware Quality Testing
Software Quality Testing
 
Chapter 8 software testing
Chapter 8 software testingChapter 8 software testing
Chapter 8 software testing
 
Static analysis works for mission-critical systems, why not yours?
Static analysis works for mission-critical systems, why not yours? Static analysis works for mission-critical systems, why not yours?
Static analysis works for mission-critical systems, why not yours?
 
TMPA-2017: 5W+1H Static Analysis Report Quality Measure
TMPA-2017: 5W+1H Static Analysis Report Quality MeasureTMPA-2017: 5W+1H Static Analysis Report Quality Measure
TMPA-2017: 5W+1H Static Analysis Report Quality Measure
 
White box testing
White box testingWhite box testing
White box testing
 
REMI: Defect Prediction for Efficient API Testing (

ESEC/FSE 2015, Industria...
REMI: Defect Prediction for Efficient API Testing (

ESEC/FSE 2015, Industria...REMI: Defect Prediction for Efficient API Testing (

ESEC/FSE 2015, Industria...
REMI: Defect Prediction for Efficient API Testing (

ESEC/FSE 2015, Industria...
 
Software Testing Techniques
Software Testing TechniquesSoftware Testing Techniques
Software Testing Techniques
 
Unit 3 Control Flow Testing
Unit 3   Control Flow TestingUnit 3   Control Flow Testing
Unit 3 Control Flow Testing
 
Control Flow Testing
Control Flow TestingControl Flow Testing
Control Flow Testing
 
Review Participation in Modern Code Review: An Empirical Study of the Android...
Review Participation in Modern Code Review: An Empirical Study of the Android...Review Participation in Modern Code Review: An Empirical Study of the Android...
Review Participation in Modern Code Review: An Empirical Study of the Android...
 
White Box Testing
White Box TestingWhite Box Testing
White Box Testing
 
Unit1
Unit1Unit1
Unit1
 
Measuring maintainability; software metrics explained
Measuring maintainability; software metrics explainedMeasuring maintainability; software metrics explained
Measuring maintainability; software metrics explained
 
Software Testing Techniques
Software Testing TechniquesSoftware Testing Techniques
Software Testing Techniques
 

Viewers also liked

A Metric for Code Readability
A Metric for Code ReadabilityA Metric for Code Readability
A Metric for Code Readability
Ray Buse
 
PhD Proposal talk
PhD Proposal talkPhD Proposal talk
PhD Proposal talk
Ray Buse
 
Documentation Inference for Exceptions
Documentation Inference for ExceptionsDocumentation Inference for Exceptions
Documentation Inference for Exceptions
Ray Buse
 
Analytics for Software Development
Analytics for Software DevelopmentAnalytics for Software Development
Analytics for Software Development
Ray Buse
 
Automatically Describing Program Structure and Behavior (PhD Defense)
Automatically Describing Program Structure and Behavior (PhD Defense)Automatically Describing Program Structure and Behavior (PhD Defense)
Automatically Describing Program Structure and Behavior (PhD Defense)
Ray Buse
 
MSR End of Internship Talk
MSR End of Internship TalkMSR End of Internship Talk
MSR End of Internship Talk
Ray Buse
 
Information Needs for Software Development Analytics
Information Needs for Software Development AnalyticsInformation Needs for Software Development Analytics
Information Needs for Software Development Analytics
Ray Buse
 

Viewers also liked (9)

A Metric for Code Readability
A Metric for Code ReadabilityA Metric for Code Readability
A Metric for Code Readability
 
PhD Proposal talk
PhD Proposal talkPhD Proposal talk
PhD Proposal talk
 
Documentation Inference for Exceptions
Documentation Inference for ExceptionsDocumentation Inference for Exceptions
Documentation Inference for Exceptions
 
Automatically Documenting Program Changes
Automatically Documenting Program ChangesAutomatically Documenting Program Changes
Automatically Documenting Program Changes
 
Synthesizing API Usage Examples
Synthesizing API Usage Examples Synthesizing API Usage Examples
Synthesizing API Usage Examples
 
Analytics for Software Development
Analytics for Software DevelopmentAnalytics for Software Development
Analytics for Software Development
 
Automatically Describing Program Structure and Behavior (PhD Defense)
Automatically Describing Program Structure and Behavior (PhD Defense)Automatically Describing Program Structure and Behavior (PhD Defense)
Automatically Describing Program Structure and Behavior (PhD Defense)
 
MSR End of Internship Talk
MSR End of Internship TalkMSR End of Internship Talk
MSR End of Internship Talk
 
Information Needs for Software Development Analytics
Information Needs for Software Development AnalyticsInformation Needs for Software Development Analytics
Information Needs for Software Development Analytics
 

Similar to The Road Not Taken: Estimating Path Execution Frequency Statically

Efficient JavaScript Mutation Testing
Efficient JavaScript Mutation TestingEfficient JavaScript Mutation Testing
Efficient JavaScript Mutation Testing
SALT Lab @ UBC
 
Reverse Engineering automation
Reverse Engineering automationReverse Engineering automation
Reverse Engineering automation
Positive Hack Days
 
New software testing-techniques
New software testing-techniquesNew software testing-techniques
New software testing-techniques
Fincy V.J
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
poonam.rwalia
 
Software testing strategies
Software testing strategiesSoftware testing strategies
Software testing strategies
Krishna Sujeer
 

Similar to The Road Not Taken: Estimating Path Execution Frequency Statically (20)

Efficient JavaScript Mutation Testing
Efficient JavaScript Mutation TestingEfficient JavaScript Mutation Testing
Efficient JavaScript Mutation Testing
 
7-White Box Testing.ppt
7-White Box Testing.ppt7-White Box Testing.ppt
7-White Box Testing.ppt
 
Reverse Engineering automation
Reverse Engineering automationReverse Engineering automation
Reverse Engineering automation
 
Debug me
Debug meDebug me
Debug me
 
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
Parasoft .TEST, Write better C# Code Using  Data Flow Analysis Parasoft .TEST, Write better C# Code Using  Data Flow Analysis
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
 
Artificial software diversity: automatic synthesis of program sosies
Artificial software diversity: automatic synthesis of program sosiesArtificial software diversity: automatic synthesis of program sosies
Artificial software diversity: automatic synthesis of program sosies
 
Compiler Construction for DLX Processor
Compiler Construction for DLX Processor Compiler Construction for DLX Processor
Compiler Construction for DLX Processor
 
Static Analysis and Verification of C Programs
Static Analysis and Verification of C ProgramsStatic Analysis and Verification of C Programs
Static Analysis and Verification of C Programs
 
New software testing-techniques
New software testing-techniquesNew software testing-techniques
New software testing-techniques
 
SWE-6 TESTING.pptx
SWE-6 TESTING.pptxSWE-6 TESTING.pptx
SWE-6 TESTING.pptx
 
Defense
DefenseDefense
Defense
 
Defense
DefenseDefense
Defense
 
SE2023 0401 Software Coding and Testing.pptx
SE2023 0401 Software Coding and Testing.pptxSE2023 0401 Software Coding and Testing.pptx
SE2023 0401 Software Coding and Testing.pptx
 
TMPA-2017: Evolutionary Algorithms in Test Generation for digital systems
TMPA-2017: Evolutionary Algorithms in Test Generation for digital systemsTMPA-2017: Evolutionary Algorithms in Test Generation for digital systems
TMPA-2017: Evolutionary Algorithms in Test Generation for digital systems
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
Software testing strategies
Software testing strategiesSoftware testing strategies
Software testing strategies
 
A WHITE BOX TESTING TECHNIQUE IN SOFTWARE TESTING : BASIS PATH TESTING
A WHITE BOX TESTING TECHNIQUE IN SOFTWARE TESTING : BASIS PATH TESTINGA WHITE BOX TESTING TECHNIQUE IN SOFTWARE TESTING : BASIS PATH TESTING
A WHITE BOX TESTING TECHNIQUE IN SOFTWARE TESTING : BASIS PATH TESTING
 
Chap07
Chap07Chap07
Chap07
 
11 whiteboxtesting
11 whiteboxtesting11 whiteboxtesting
11 whiteboxtesting
 
connecting discrete mathematics and software engineering
connecting discrete mathematics and software engineeringconnecting discrete mathematics and software engineering
connecting discrete mathematics and software engineering
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

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
 
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
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
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...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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...
 

The Road Not Taken: Estimating Path Execution Frequency Statically

  • 1. Estimating Path Execution Frequency StaticallyRay Buse Wes Weimer THE ROAD NOT TAKENICSE 2009 Vancouver, BC
  • 2. 2 The Big Idea  Developers often have a expectations about common and uncommon cases in programs  The structure of code they write can sometimes reveal these expectations
  • 3. 3 Example public V function(K k , V v) { if ( v == null ) throw new Exception(); if ( c == x ) r(); i = k.h(); t[i] = new E(k, v); c++; return v; }
  • 4. 4 Example public V function(K k , V v) { if ( v == null ) throw new Exception(); if ( c == x ) restructure(); i = k.h(); t[i] = new E(k, v); c++; return v; } Exception Invocation that changes a lot of the object state Some computation
  • 5. 5 Path 1 public V function(K k , V v) { if ( v == null ) throw new Exception(); if ( c == x ) restructure(); i = k.h(); t[i] = new E(k, v); c++; return v; }
  • 6. 6 public V function(K k , V v) { if ( v == null ) throw new Exception(); if ( c == x ) restructure(); i = k.h(); t[i] = new E(k, v); c++; return v; } Path 2
  • 7. 7 Path 3 public V function(K k , V v) { if ( v == null ) throw new Exception(); if ( c == x ) restructure(); i = k.h(); t[i] = new E(k, v); c++; return v; }
  • 8. 8 HashTable: put public V put(K key , V value) { if ( value == null ) throw new Exception(); if ( count >= threshold ) rehash(); index = key.hashCode() % length; table[index] = new Entry(key, value); count++; return value; } *simplified from java.util.HashTable jdk6.0
  • 9. 9 Intuition How a path modifies program state may correlate with it’s runtime execution frequency  Paths that change a lot of state are rare  Exceptions, initialization code, recovery code etc  Common paths tend to change a small amount of state Stack State + Heap State
  • 10. 10 More Intuition  Number of branches  Number of method invocations  Length  Percentage of statements in a method executed  …
  • 11. 11 Hypothesis We can accurately predict the runtime frequency of program paths by analyzing their static surface features Goals:  Know what programs are likely to do without having to run them (Produce a static profile)  Understand the factors that are predictive of execution frequency
  • 12. 12 Our Path  Intuition  Candidates for static profiles  Our approach  a descriptive model of path frequency  Some Experimental Results
  • 13. 13 Applications for Static Profiles  Indicative (dynamic) profiles are often hard to get Profile information can improve many analyses  Profile guided optimization  Complexity/Runtime estimation  Anomaly detection  Significance of difference between program versions  Prioritizing output from other static analyses
  • 14. 14 Approach  Model path with a set of features that may correlate with runtime path frequency  Learn from programs for which we have indicative workloads  Predict which paths are most or least likely in other programs
  • 15. 15 Experimental Components  Path Frequency Counter  Input: Program, Input  Output: List of paths + frequency count for each  Descriptive Path Model  Classifier
  • 16. 16 Our Definition of Path  Statically enumerating full program paths doesn't scale  Choosing only intra-method paths doesn't give us enough information  Compromise: Acyclic Intra-Class Paths  Follow execution from public method entry point until return from class  Don’t follow back edges
  • 17. 17 Experimental Components  Path Frequency Counter  Input: Program, Input  Output: List of paths + frequency count for each  Descriptive Path Model  Input: Path  Output: Feature Vector describing the path  Classifier
  • 18. 18 Count Coverage Feature • pointer comparisons • new • this • all variables • assignments • dereferences • • fields • • fields written • • statements in invoked method • goto stmts • if stmts • local invocations • • local variables • non-local invocations • • parameters • return stmts • statements • throw stmts
  • 19. 19 Experimental Components  Path Frequency Counter  Input: Program, Input  Output: List of paths + frequency count for each  Descriptive Path Model  Input: Path  Output: Feature Vector describing the path  Classifier  Input: Feature Vector  Output: Frequency Estimate
  • 20. 20 Classifier: Logistic Regression  Learn a logistic function to estimate the runtime frequency of a path Likely to be taken Not likely to be taken Input path {x1, x2 … xn}
  • 21. 21 Model Evaluation  Use the model to rank all static paths in the program  Measure how much of total program runtime is spent:  On the top X paths for each method  On the top X% of all paths  Also, compare to static branch predictors  Cross validation on Spec JVM98 Benchmarks  When evaluating on one, train on the others
  • 22. 22 Evaluation: Top Paths Choose 5% of all paths and get 50% of runtime behavior Choose 1 path per method and get 94% of runtime behavior
  • 23. 23 Evaluation: Static Branch Predictor We are even a reasonable choice for static branch prediction Branch Taken; Forward Not Taken A set of heuristics Always choose the higher frequency path
  • 24. 24 Model Analysis: Feature Power Exceptions are predictive but rare Many features “tie” Path length matters most More assignment statements → lower frequency
  • 25. 25 Conclusion A formal model that statically predicts relative dynamic path execution frequencies A generic tool (built using that model) that takes only the program source code (or bytecode) as input and produces  for each method, an ordered list of paths through that method The promise of helping other program analyses and transformations
  • 27. 27 Evaluation by Benchmark 1.0 = perfect 0.67 = return all or return nothing