Hybrid Optimizations: Which Optimization Algorithm to Use?
We introduce a new class of compiler heuristics: hybrid optimizations. Hybrid optimizations choose dynamically at compile time which optimization algorithm to apply from a set of different algorithms that implement the same optimization. They use a heuristic to predict the most appropriate algorithm for each piece of code being optimized. Specifically, we construct a hybrid register allocator that chooses between linear scan and graph coloring register allocation. Linear scan is more efficient, but sometimes less effective; graph coloring is generally more expensive, but sometimes more effective. Our setting is Java JIT compilation, which makes optimization algorithm efficiency particularly important.
Our hybrid allocator decides, based on features of a method, which algorithm to apply to that method. We used supervised learning to induce the decision heuristic. We evalute our technique within Jikes RVM  and show on average it outperforms graph coloring by 9% and linear scan by 3% for a typical compilation scenario. To our knowledge, this is the first time anyone has used heuristics induced by machine learning to select between different optimization algorithms.
KeywordsAllocation Algorithm Graph Coloring Training Instance Heuristic Function Hybrid Optimization
- 1.Alpern, B., Attanasio, C.R., Barton, J.J., Burke, M.G., Cheng, P., Choi, J.-D., Cocchi, A., Fink, S.J., Grove, D., Hind, M., Hummel, S.F., Lieber, D., Litvinov, V., Mergen, M.F., Ngo, T., Russell, J.R., Sarkar, V., Serrano, M.J., Shepherd, J.C., Smith, S.E., Sreedhar, V.C., Srinivasan, H., Whaley, J.: The Jalapeño virtual machine. IBM Systems Journal 39(1), 211–238 (2000)CrossRefGoogle Scholar
- 2.Appel, A., George, L.: Optimal spilling for CISC machines with few registers. In: Proceedings of the ACM SIGPLAN 2001 Conference on Programming Language Design and Implementation, Snowbird, Utah, June 2001, pp. 243–253. Association of Computing Machinery (2001)Google Scholar
- 4.Bernstein, D., Goldin, D.Q., Golumbic, M.C., Mansour, Y., Nahshon, I., Pinter, R.Y.: Spill code minimization techniques for optimizing compilers. In: SIGPLAN 1989 Conference on Programming Language Design and Implementation, Portland, Oregon, June 1989, pp. 258–263. ACM Press, New York (1989)CrossRefGoogle Scholar
- 8.Chaitin, G.J.: Register allocation and spilling via graph coloring. In: Proceedings of the ACM SIGPLAN 1982 Conference on Programming Language Design and Implementation, Boston, Massachusetts, June 1982, pp. 98–101. ACM Press, New York (1982)Google Scholar
- 9.Cohen, W.W.: Fast effective rule induction. In: Proceedings of the Twelfth International Conference on Machine Learning, Lake Tahoe CA, November 1995, pp. 115–123. Morgan Kaufmann, San Francisco (1995)Google Scholar
- 11.Lagoudakis, M.G., Littman, M.L.: Algorithm selection using reinforcement learning. In: Proceedings of the 17th International Conference on Machine Learning, Stanford CA, pp. 511–518. Morgan Kaufmann, San Francisco (2000)Google Scholar
- 14.Standard Performance Evaluation Corporation (SPEC), Fairfax, VA. SPEC JVM 1998 Benchmarks (1998)Google Scholar
- 15.Stephenson, M., Amarasinghe, S., Martin, M., O’Reilly, U.-M.: Meta optimization: Improving compiler heuristics with machine learning. In: Proceedings of the ACM SIGPLAN 2003 Conference on Programming Language Design and Implementation, San Diego, Ca, June 2003, pp. 77–90. ACM Press, New York (2003)CrossRefGoogle Scholar