Profile Guided Optimization Using Path Identifiers for Stale Data

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Profile-guided compiler optimization (PGO) faces scalability bottlenecks with frequent code changes, as traditional methods require repeating instrumentation, training, and optimization phases, leading to stale profile data and poor optimization decisions when source code changes occur, especially in large code bases.

Innovation Solution

The system uses path profiling to identify unique paths through a program's call graph, assigning path increments and identifiers to enable the use of stale profile data for optimization decisions, allowing PGO optimizations along edited function call graph paths, thereby avoiding the need for complete re-instrumentation and re-training.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If traditional PGO methods are used with frequent code changes, then optimization decisions become stale and inaccurate, but re-running full instrumentation and training phases increases time and resource consumption

Engineering Contradiction:
Improveoptimization decision accuracyVSAvoidre-instrumentation and re-training time
Core Design Contradiction:
Measurement precisionVSLoss of time

Solution Approach 1:

The patent segments the profile data into path-specific components by assigning unique path identifiers to different execution paths through the call graph. This allows the system to selectively reuse only the relevant path profile data from previous versions, rather than requiring complete re-instrumentation. The segmentation enables fine-grained control over which profile data remains valid after source code changes.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent performs preliminary path identifier assignment and profile data validation before compilation. By pre-computing path identifiers and checking their validity against the current call graph structure, the system prepares optimization decisions in advance, avoiding the need for time-consuming re-instrumentation and re-training phases when code changes occur.

Inventive Principle:
Principle #10Preliminary action

2Measurement precision

If complete re-instrumentation and re-training are performed for every source code change, then optimization decisions remain accurate, but the process becomes impractical for large code bases with frequent changes

Engineering Contradiction:
Improveoptimization decision accuracyVSAvoidengineering system efficiency
Core Design Contradiction:
Measurement precisionVSProductivity

Solution Approach 1:

The patent divides the monolithic PGO process into manageable segments: path identifier assignment, profile data validation, and selective optimization. This segmentation allows the system to process only the affected portions of the code base rather than requiring complete re-instrumentation, significantly improving productivity for large code bases with frequent changes.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent applies partial action by reusing valid profile data for unchanged paths while only re-instrumenting and re-training for modified paths. This selective approach performs less work than complete re-instrumentation but maintains sufficient accuracy for optimization decisions, making the process practical for frequent code changes in large code bases.

Inventive Principle:
Principle #16Partial or excessive action

3Reliability

If stale profile data is discarded for edited functions, then optimization decisions remain reliable, but the system cannot leverage previous profiling efforts for modified code

Engineering Contradiction:
Improveoptimization decision reliabilityVSAvoidusable profile data
Core Design Contradiction:
ReliabilityVSLoss of information

Solution Approach 1:

The patent introduces dynamics by making profile data validity conditional rather than static. Profile data is marked as valid or invalid based on the current validity status of its associated path identifier, allowing the system to dynamically adapt to source code changes. This enables reliable reuse of profile data for unchanged paths while automatically invalidating data for modified paths.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The patent uses path identifiers as intermediaries between the source code and profile data. These identifiers act as a bridge that connects profile data to specific execution paths, allowing the system to validate and reuse profile data indirectly through the intermediary layer without directly analyzing the source code changes.

Inventive Principle:
Principle #24Intermediary (Mediator)

4Productivity

If path profiling is implemented to enable stale profile data reuse, then PGO results improve for modified code, but the system complexity increases due to path identifier management

Engineering Contradiction:
ImprovePGO optimization efficiencyVSAvoidpath identifier management complexity
Core Design Contradiction:
ProductivityVSDevice complexity

Solution Approach 1:

The patent implements self-service by having the compiler automatically generate and manage path identifiers during the compilation process. The system assigns path increments to callees and computes path identifiers without requiring external intervention or complex manual management, reducing the perceived complexity while maintaining the benefits of path-specific profile data reuse.

Inventive Principle:
Principle #25Self-service

Data Source

PatentUS9348567B2Profile guided optimization in the presence of stale profile data
Publication Date: 2016.05.24 MICROSOFT TECHNOLOGY LICENSING LLC
  • US9348567B2 patent drawing
  • US9348567B2 patent drawing
  • US9348567B2 patent drawing

AI summary

Profile guided optimization (PGO) in the presence of stale profile data as described herein can be based on path profiling, whereby different paths through a program's call graph are uniquely identified. Stale profile data is data collected in a training run of a previous version of the program. Profile data can be collected along these paths and optimization decisions can be made using the collected data. The paths can be numbered using an algorithm that assigns path increments to all the callees of a function. The path increment assignments (which can be stored in the profile database) can be used to locate the profile data for that path and to make corresponding optimization decisions. PGO optimizations along call graph paths involving edited functions can be performed.