Online Subpath Profiling

David Oren, Yossi Matias, Shmuel SagivCC 2002 · DOI

Abstract

Modern Just-In-Time (JIT) compilers rely on accurate profiling data to optimize code during execution. However, traditional path profiling often fails to capture "hot" sub-segments within larger, infrequently executed paths. This paper introduces Online Subpath Profiling (OSP), an efficient algorithm that identifies these hot subpaths in real-time. By employing adaptive sampling and concise encoding, OSP achieves high accuracy with a memory footprint of less than 65 KB and runtime overhead typically under 20%.

The Hot Subpath Paradox

A significant challenge in code optimization is that a subpath can be "hot" (frequently executed) even if every full path containing it is "cold." Traditional profilers focusing on whole paths or acyclic segments may miss these critical optimization opportunities. OSP addresses this by profiling at the subpath level, allowing compilers to identify and optimize the shared "hot core" of multiple paths.

Figure 1: Illustration of subpath counts within a control flow graph, demonstrating how hot subpaths can exist within cold full paths.

As shown in the figure above, specific sub-segments (like [3456]) can accumulate high execution counts even when the branching paths leading into or out of them vary significantly. This granularity is essential for JIT compilers to make informed optimization decisions during program execution.

The OSP Algorithm

The OSP algorithm is designed for low-overhead, online operation. It avoids the computational cost of counting every subpath execution through several key techniques:

  1. Adaptive Sampling and Deterministic Skipping: OSP uses a "skip-and-sample" approach. Instead of making a random decision at every basic block, it calculates a deterministic skip value—the number of blocks to ignore before the next sample. This significantly reduces the overhead of the profiling logic.
Figure 2: The skip-and-sample mechanism used by OSP to reduce runtime overhead.
  1. Power-of-Two Constraints: To manage the search space, OSP only tracks subpaths with lengths that are powers of two ($2^n$). This ensures that any hot subpath of length $k$ will have a representative subpath of at least length $k/2$ in the sample, providing a good approximation while drastically reducing memory requirements.
  2. Concise Encoding: Subpaths are represented by unique IDs generated via XORing basic block identifiers. This allows the system to store simple (ID, count) pairs in memory rather than complex path structures.

Experimental Evaluation

The authors evaluated a Java prototype of OSP using the Soot instrumentation framework across several benchmarks, including the Java Grande suite, JLex, and javac. These benchmarks cover a range of computational intensities and logic complexities.

Key Results

  • Minimal Memory Usage: Across all tests, OSP required only 40 to 65 kilobytes of memory, making it highly efficient for production environments.
  • Low Runtime Overhead: The core sampling logic typically added less than 20% overhead. The authors anticipate this would decrease further if integrated natively into a Virtual Machine.
  • High Accuracy: In the FFT benchmark, OSP estimated the count of the primary hot subpath with 99.06% accuracy.
  • Early Detection: OSP identified the "true" hot paths within the first 6-12% of program execution, enabling early-stage JIT optimizations.

Conclusion and Future Work

OSP provides a robust framework for online subpath profiling, successfully balancing the trade-off between profiling granularity and runtime performance. While the current XOR-based encoding has limitations—such as blocks canceling out if they appear an even number of times—future iterations could utilize more robust representations like prefix trees (tries). Additionally, incorporating "path costs" (e.g., memory latency) could further refine the profiler's ability to identify the most impactful optimization targets.

Summary updated

BibTeX
@inproceedings{oren2002online,
  author = {David Oren and Yossi Matias and Shmuel Sagiv},
  title = {{Online Subpath Profiling}},
  booktitle = {CC},
  year = {2002},
  doi = {10.1007/3-540-45937-5\_8},
}

Loading related content...

Figure