TL;DR
Shackleton is a new, high-performance C-based framework for Linear Genetic Programming (LGP) designed to automate the search for optimal LLVM compiler pass sequences. By evolving custom optimization pipelines, Shackleton consistently outperforms standard LLVM optimization levels (like -O2) for specific, computationally intensive applications.
What Problem Does This Paper Address?
Modern compilers like LLVM use "passes"—individual optimization steps—to improve code performance. However, the standard sequences provided by compilers (e.g., -O1, -O2, -O3) are "one-size-fits-all" solutions designed for general-purpose use. Because the number of possible pass combinations is astronomical, finding the perfect sequence for a specific piece of software is an NP-complete search problem.
While Evolutionary Algorithms (EAs) are well-suited for this kind of exploration, existing frameworks are often slow, written in high-level languages like Python, or require deep domain expertise to adapt to new problems. The authors introduce Shackleton to bridge this gap, providing a generalized, efficient LGP framework that can be applied to complex systems like LLVM with minimal background knowledge.
Methods
Shackleton utilizes Linear Genetic Programming (LGP), where programs (or in this case, compiler pass sequences) are represented as linear strings of instructions.
Key components of the Shackleton approach include:
- The Evolutionary Loop: The framework generates an initial random population, evaluates their fitness (program runtime), and uses elitism to carry the best performers into the next generation.
- Novel Offspring Selection: Shackleton employs a unique "brood selection" mechanism. Instead of simple crossover, parents produce a "nest" of four offspring. The two best individuals from the combined pool of the four children and two parents are selected for the next generation. This process is detailed in Figure 2.
- Fitness Hashing: To reduce the massive overhead of re-running benchmarks, the framework stores the results of previously evaluated sequences in a hash table.
- Hyperparameter Tuning: The authors used the Taguchi Method, a statistical approach that allows for efficient exploration of parameters like crossover rate, mutation rate, and tournament size without needing a full factorial grid search.
Datasets
The authors evaluated Shackleton on two target programs representing complex, NP-complete problems:
- ACOTSP: An Ant Colony Optimization algorithm for the Traveling Salesman Problem.
- SSP: A backtracking algorithm for the Subset Sum Problem.
These were chosen because they contain recursive loops and complex logic that serve as prime targets for compiler-level optimization.
Key Insights and Ideas
- Diversity Over Depth: The researchers found that a large population size (e.g., 200 individuals) evolving over a few generations (10) was significantly more effective than a small population (10 individuals) evolving over many generations (200). In the sparse search space of compiler passes, genetic diversity is more valuable than long-term convergence.
- Variance is Noise: Interestingly, including runtime variance in the fitness function (to prefer "stable" sequences) actually degraded performance. The authors concluded that variance was largely due to external system noise (shared cluster resources) rather than the optimization sequences themselves.
- Efficiency via C: By writing the framework entirely in C, the authors leveraged low-level memory control and runtime efficiency, which is rare in the EA community but vital for heavy-duty tasks like compiler optimization.
Key Results
Shackleton demonstrated a clear ability to surpass standard compiler defaults:
- Robustness: In 90% of experimental runs, Shackleton-generated sequences were faster than the standard LLVM
-O2optimization. - Performance Gains: The framework achieved an average improvement of 4.77% over
-O2and up to 19.12% improvement compared to unoptimized code. - Computational Savings: Implementing fitness hashing drastically reduced the overhead runtime. As shown in Figure 8, re-evaluating individuals (Exp 8) was nearly three times slower than using a hash table (Exp 6).
Limitations and Future Work
While successful, the current implementation has some constraints:
- Pass Subset: The study only explored a subset of LLVM passes, omitting analysis and utility passes to avoid automation conflicts.
- Fixed Parameters: Certain internal parameters, such as the "brood/nest" size, were fixed during these experiments.
- Future Directions: The authors plan to widen the scope of included passes and allow for user-defined passes. They also aim to make the framework even more generic, allowing for hyperparameter tuning of the evolutionary mechanism itself to further refine results for different use cases.
Summary updated