Exploiting inter-sequence correlations for program behavior prediction

Bo Wu, Zhijia Zhao, Xipeng Shen, Yunlian Jiang, Yaoqing Gao, Raúl SilveraOOPSLA 2012

TL;DR

This paper introduces "behavior sequence prediction," a novel approach that leverages statistical correlations between different program constructs' behavior sequences to predict future program behavior. This method significantly outperforms traditional locality-based predictors, leading to substantial speedups in dynamic optimizations like function version selection.

What Problem Does This Paper Address?

Modern software optimizations, such as dynamic compilation and resource management, heavily rely on predicting future program behavior. Existing predictors primarily exploit "locality" – the assumption that past behavior is a good indicator of future behavior (e.g., a function call will return a similar value as the previous one). However, this approach has inherent limitations: it struggles with infrequent events (low locality) and situations where behavior is inherently random or complex. This paper addresses these limitations by exploring a new source of predictive information: statistical correlations between the sequences of behaviors of different program entities (like loops or functions).

Methods

The core of this work is the development of a sequence predictor. This predictor operates in three main stages:

  1. Offline Training:
    • Pattern Recognition: The system first classifies program behavior sequences (e.g., loop trip-counts) into a hierarchical taxonomy of patterns (e.g., constant, linear, repetitive phases). Each sequence is then represented by a "feature tuple" containing its class and pattern parameters.
  2. Correlation Analysis & Model Construction: Using these feature tuples from many training runs, the system identifies statistical correlations between the sequences of different program constructs. It then builds predictive models (e.g., linear regression, decision trees) that map the behavior sequence of one construct to the predicted sequence of another.
  3. Runtime Prediction:
    • During program execution, when a predictor construct's behavior is observed, its pattern vector is computed.
  4. This vector is fed into the pre-trained predictive models to generate a predicted pattern vector for a correlated target construct.
  5. From this predicted pattern vector, the entire future behavior sequence of the target construct can be generated.

This approach allows for large-scope and proactive predictions, overcoming the reactive nature and limited scope of traditional locality-based methods.

Datasets

The primary dataset used in this paper consists of loop trip-count sequences collected from eleven C programs in the SPEC CPU2006 benchmark suite. The authors also included one program from SPEC CPU2000 ("parser"). They collected data from over two hundred runs across these programs, involving billions of loop invocations. For training and evaluation, they used 20 distinct inputs per program to capture a wide range of behaviors.

Key Insights and Ideas

  • Inter-sequence correlations are a rich source of predictive information: Beyond simple locality, the way one program construct's behavior sequence evolves can strongly predict another's, even if they are not directly data-dependent.
  • A taxonomy of behavior sequences is crucial: Categorizing sequences into a manageable set of patterns (constant, linear, logarithmic, square root, square, repetitive phases, etc.) simplifies analysis and enables effective modeling.
  • Sequence prediction offers proactivity and large scope: Unlike locality-based methods that react to recent events, sequence prediction can forecast behavior far in advance, enabling more effective optimizations.
  • Cross-run stability of patterns is key: While the exact values in a sequence can vary significantly across different program runs, the underlying shape or pattern of the sequence tends to be stable, making offline training viable.

Key Results

  • Prediction Accuracy: The sequence predictor achieved an average accuracy of 91% for predicting loop trip-count sequences, significantly outperforming locality-based predictors which averaged 76%.
  • Dynamic Function Version Selection: This approach yielded substantial speedups, with an average of 19% across several real-world utility applications. In some cases, it achieved speedups of 34-65% compared to static compilation. For the DataMine program, it achieved 100% signature prediction accuracy, leading to perfect version selection.
  • Loop Importance Prediction: The sequence predictor achieved 98% accuracy in estimating loop importance, outperforming locality-based methods (81% average) and offline profiling (lower accuracy due to input sensitivity).

Limitations and Future Work

  • Special Treatment for Complex Sequences: Prediction for certain complex sequence classes (C2.1.2, C2.2.3, C3.2, C3.3) requires special handling, and for some (C2.1.2, C3.3), no prediction is conducted.
  • Runtime Overhead: While generally lightweight, recording predictor loop sequences for complex patterns (C3.1) can incur more overhead. The authors suggest selecting predictor loops that have large variances but don't require extensive instrumentation.
  • Complementary to Locality: Correlation-based prediction is presented as a complement, not a replacement, for locality-based prediction. Combining them effectively is an area for future exploration.
  • Extensibility: The authors suggest that the concepts of inter-sequence correlations and sequence prediction are extensible to other program behaviors beyond loop trip-counts (e.g., function return values, memory addresses) and could benefit optimizations at OS and architecture levels.

Summary updated

BibTeX
@inproceedings{wu2012exploiting,
  author = {Bo Wu and Zhijia Zhao and Xipeng Shen and Yunlian Jiang and Yaoqing Gao and Raúl Silvera},
  title = {{Exploiting inter-sequence correlations for program behavior prediction}},
  booktitle = {OOPSLA},
  year = {2012},
  doi = {10.1145/2384616.2384678},
}

Loading related content...

Figure