Investigating Magic Numbers: Improving the Inlining Heuristic in the Glasgow Haskell Compiler (Video, Haskell 2022)
Celeste Hollenbeck, Michael F. P. O'Boyle, and Michel Steuwer
(University of Edinburgh, UK; University of Edinburgh, UK; University of Edinburgh, UK)
Abstract: 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 widespread 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.
Article: [ Ссылка ]
Supplementary archive: [ Ссылка ] (Badges: Artifacts Available)
ORCID: [ Ссылка ], [ Ссылка ], [ Ссылка ]
Video Tags: Inlining, Haskell, GHC, icfpws22haskellmain-p34-p, doi:10.1145/3546189.3549918, doi:10.1145/3554300, orcid:0000-0002-2922-5954, orcid:0000-0003-1619-5052, orcid:0000-0001-5048-0741, Artifacts Available
Presentation at the Haskell 2022 conference, September 15–16, 2022, [ Ссылка ]
Sponsored by ACM, ACM SIGPLAN, [ Ссылка ]
Ещё видео!