HiPErJiT: A Profile-Driven Just-in-Time Compiler for Erlang

We introduce HiPErJiT, a profile-driven Just-in-Time compiler for the BEAM ecosystem based on HiPE, the High Performance Erlang compiler. HiPErJiT uses runtime profiling to decide which modules to compile to native code and which of their functions to inline and type-specialize. HiPErJiT is integrated with the runtime system of Erlang/OTP and preserves aspects of Erlang's compilation which are crucial for its applications: most notably, tail-call optimization and hot code loading at the module level. We present HiPErJiT's architecture, describe the optimizations that it performs, and compare its performance with BEAM, HiPE, and Pyrlang. HiPErJiT offers performance which is about two times faster than BEAM and almost as fast as HiPE, despite the profiling and compilation overhead that it has to pay compared to an ahead-of-time native code compiler. But there also exist programs for which HiPErJiT's profile-driven optimizations allow it to surpass HiPE's performance.

[1]  Hisao Tamaki,et al.  Program transformation through meta-shifting , 2009, New Generation Computing.

[2]  Konstantinos Sagonas,et al.  Detecting Software Defects in Telecom Applications Through Lightweight Static Analysis: A War Story , 2004, APLAS.

[3]  R. Kent Dybvig,et al.  An infrastructure for profile-driven dynamic recompilation , 1998, Proceedings of the 1998 International Conference on Computer Languages (Cat. No.98CB36225).

[4]  Nikolai Tillmann,et al.  SPUR: a trace-based JIT compiler for CIL , 2010, OOPSLA.

[5]  Vasanth Bala,et al.  Dynamo: a transparent dynamic optimization system , 2000, SIGP.

[6]  Mauricio J. Serrano,et al.  The starjit compiler: a dynamic compiler for managed runtime environments , 2003 .

[7]  James Demmel,et al.  IEEE Standard for Floating-Point Arithmetic , 2008 .

[8]  Urs Hölzle,et al.  Optimizing dynamically-dispatched calls with run-time type feedback , 1994, PLDI '94.

[9]  John Hughes,et al.  The Design of a Pretty-printing Library , 1995, Advanced Functional Programming.

[10]  Gilbert Joseph Hansen,et al.  Adaptive systems for the dynamic run-time optimization of programs. , 1974 .

[11]  Guy L. Steele Debunking the “expensive procedure call” myth or, procedure call implementations considered harmful or, LAMBDA: The Ultimate GOTO , 1977, ACM '77.

[12]  Mor Harchol-Balter,et al.  Exploiting process lifetime distributions for dynamic load balancing , 1995, SIGMETRICS.

[13]  Mikael Pettersson,et al.  A high performance Erlang system , 2000, PPDP '00.

[14]  Matthew Arnold,et al.  Adaptive optimization in the Jalapeño JVM , 2000, OOPSLA '00.

[15]  Michael Franz,et al.  Continuous program optimization: A case study , 2003, TOPL.

[16]  K. Roberts,et al.  Thesis , 2002 .

[17]  Peter H. Golde,et al.  C# Language Specification , 2003 .

[18]  Vikram S. Adve,et al.  LLVM: a compilation framework for lifelong program analysis & transformation , 2004, International Symposium on Code Generation and Optimization, 2004. CGO 2004..

[19]  Ben Hardekopf,et al.  Deoptimization for dynamic language JITs on typed, stack-based virtual machines , 2014, VEE '14.

[20]  Mason Chang,et al.  Trace-based just-in-time type specialization for dynamic languages , 2009, PLDI '09.

[21]  Konstantinos Sagonas,et al.  Unboxed Compilation of Floating Point Arithmetic in a Dynamically Typed Language Environment , 2002, IFL.

[22]  Markus Mock,et al.  A retrospective on: "an evaluation of staged run-time optimizations in DyC" , 2004, SIGP.

[23]  L. Peter Deutsch,et al.  Efficient implementation of the smalltalk-80 system , 1984, POPL.

[24]  Hidehiko Masuhara,et al.  Improving Sequential Performance of Erlang Based on a Meta-tracing Just-In-Time Compiler , 2016, TFP.

[25]  Sam Tobin-Hochstadt,et al.  The Racket Manifesto , 2015, SNAPL.

[26]  WimmerChristian,et al.  Design of the Java HotSpot client compiler for Java 6 , 2008 .

[27]  James M. Stichnoth,et al.  Practicing JUDO: Java under dynamic optimizations , 2000, PLDI '00.

[28]  Mikael Pettersson,et al.  The HiPE/x86 Erlang Compiler: System Description and Performance Evaluation , 2002, FLOPS.

[29]  Hidehiko Masuhara,et al.  Pyrlang: a high performance Erlang virtual machine based on RPython , 2015, SPLASH.

[30]  John Aycock,et al.  A brief history of just-in-time , 2003, CSUR.

[31]  Mikael Pettersson,et al.  All you wanted to know about the HiPE compiler: (but might have been afraid to ask) , 2003, ERLANG '03.

[32]  David Grove,et al.  Adaptive online context-sensitive inlining , 2003, International Symposium on Code Generation and Optimization, 2003. CGO 2003..

[33]  Frederick Reiss,et al.  Data Triage: an adaptive architecture for load shedding in TelegraphCQ , 2005, 21st International Conference on Data Engineering (ICDE'05).

[34]  Andrew Kennedy,et al.  Compiling with continuations, continued , 2007, ICFP '07.

[35]  Konstantinos Sagonas,et al.  Practical type inference based on success typings , 2006, PPDP '06.

[36]  Craig Chambers,et al.  Making pure object-oriented languages practical , 1991, OOPSLA '91.

[37]  Andrew Ayers,et al.  Aggressive inlining , 1997, PLDI '97.

[38]  Mikael Pettersson,et al.  The development of the HiPE system: design and experience report , 2003, International Journal on Software Tools for Technology Transfer.

[39]  Sam Tobin-Hochstadt,et al.  Pycket: a tracing JIT for a functional language , 2015, ICFP.

[40]  Ken Arnold,et al.  The Java Programming Language , 1996 .

[41]  Prasad A. Kulkarni,et al.  JIT compilation policy for modern machines , 2011, OOPSLA '11.

[42]  Lars Rasmusson,et al.  BEAMJIT: a just-in-time compiling runtime for Erlang , 2014, Erlang Workshop.

[43]  Mikael Pettersson,et al.  HiPE on AMD64 , 2004, ERLANG '04.

[44]  Manuel Serrano Inline Expansion: When and How? , 1997, PLILP.

[45]  David A. Gudeman,et al.  Representing Type Information in Dynamically Typed Languages , 1993 .

[46]  University of Glasgow , 1862, Nature.

[47]  Konstantinos Sagonas,et al.  On Using Erlang for Parallelization - Experience from Parallelizing Dialyzer , 2012, Trends in Functional Programming.

[48]  André L. M. Santos,et al.  Compilation by transformation in non-strict functional languages , 1995 .

[49]  Matthew Arnold,et al.  A Survey of Adaptive Optimization in Virtual Machines , 2005, Proceedings of the IEEE.

[50]  Toshiaki Yasue,et al.  An Empirical Study of Method In-lining for a Java Just-in-Time Compiler , 2002, Java Virtual Machine Research and Technology Symposium.

[51]  Carl Friedrich Bolz,et al.  Tracing the meta-level: PyPy's tracing JIT compiler , 2009, ICOOOLPS@ECOOP.

[52]  Robert G. Burger,et al.  Efficient compilation and profile-driven dynamic recompilation in scheme , 1997 .

[53]  Jared Roesch,et al.  Improved type specialization for dynamic scripting languages , 2013, DLS '13.

[54]  Jeffrey S. Foster,et al.  Just-in-time static type checking for dynamic languages , 2016, PLDI 2016.

[55]  Konstantinos Sagonas,et al.  A language for specifying type contracts in erlang and its interaction with success typings , 2007, ERLANG '07.

[56]  R. Kent Dybvig,et al.  Fast and Effective Procedure Inlining , 1997, SAS.

[57]  Rajeev Motwani,et al.  Load shedding for aggregation queries over data streams , 2004, Proceedings. 20th International Conference on Data Engineering.

[58]  Simon L. Peyton Jones,et al.  Secrets of the Glasgow Haskell Compiler inliner , 2002, Journal of Functional Programming.

[59]  Christer Jonsson,et al.  Native Code Compilation for Erlang , 1996 .

[60]  Konstantinos Sagonas,et al.  TypEr: a type annotator of Erlang code , 2005, ERLANG '05.

[61]  Konstantinos Sagonas,et al.  ErLLVM: an LLVM backend for Erlang , 2012, Erlang '12.

[62]  Keith D. Cooper,et al.  Improvements to graph coloring register allocation , 1994, TOPL.

[63]  Joe Armstrong,et al.  Making reliable distributed systems in the presence of software errors , 2003 .

[64]  Toshiaki Yasue,et al.  Overview of the IBM Java Just-in-Time Compiler , 2000, IBM Syst. J..