Investigating Magic Numbers: Improving the Inlining Heuristic in the Glasgow Haskell Compiler
Inlining is a widely studied compiler optimization that is particularly important for functional languages such as Haskell and OCAML. The Glasgow Haskell Compiler (GHC) inliner is a heuristic of such complexity, however, that it has not significantly changed for nearly 20 years. It heavily relies on hard-coded numeric constants, or magic numbers, based on out-of-date intuition. Dissatisfaction with inlining performance has led to the wide-spread use of inlining pragmas by programmers. In this paper, we present an in-depth study of the effect of inlining on performance in functional languages. We specifically focus on the inlining behavior of GHC and present techniques to systematically explore the space of possible magic-number values, or configurations, and evaluate their performance on a set of real-world benchmarks where inline pragmas are present. Pragmas may slow down individual programs, but on average improve performance by 10%. Searching for the best configuration on a per-program basis increases this performance to an average of 27%. Searching for the best configuration for each program is, however, expensive and unrealistic, requiring repeated compilation and execution. This paper determines a new single configuration that gives a 22% improvement on average across the benchmarks. Finally, we use a simple machine learning model that predicts the best configuration on a per-program basis, giving a 26% average improvement.
Fri 16 SepDisplayed time zone: Belgrade, Bratislava, Budapest, Ljubljana, Prague change
11:00 - 12:30 | |||
11:00 30mTalk | Investigating Magic Numbers: Improving the Inlining Heuristic in the Glasgow Haskell Compiler Haskell Celeste Hollenbeck University of Edinburgh, Michael F. P. O'Boyle University of Edinburgh, Michel Steuwer University of Edinburgh | ||
11:30 30mTalk | Partial Type Constructors in Practice Haskell Apoorv Ingle University of Iowa, Alex Hubers The University of Iowa, J. Garrett Morris The University of Iowa | ||
12:00 30mTalk | Reasonable Agda is Correct Haskell: Writing Verified Haskell using agda2hs Haskell Jesper Cockx TU Delft, Lucas Escot TU Delft, Orestis Melkonian University of Edinburgh, James Chapman Input Output, Ulf Norell Gothenburg University Pre-print File Attached |