Comparison of Compilation Methods

What is a compiler? Just-in-Time Compilation Challenges

• A compiler is a piece of software that • Just-in-Time compilation (or JIT) is performed • Technically, the Java language uses converts a program written in a high- when a user or another program calls the program both AOT and JIT. It uses AOT to level programming language into to run. convert the Java code into Java instructions that the processor can • Since compilation is performed at runtime, , an intermediary language, which is then run with the JIT execute. programs using JIT often have higher startup • Compilers perform many overhead than those using AOT. compiler. This makes it more difficult optimizations on code while • JIT compilers have access to some data about the to fairly compare the two. To account translating it, such as unrolling loops program at runtime, such as the values of for this, “Java Compile and Run” or converting complex mathematical variables, that can help make optimizations that an includes this time on the graph. operations into groups of simpler AOT compiler cannot, such as more advanced • It was difficult to find a way to operations. branch prediction. compare AOT and JIT in the same • Most compilers can be divided into • Notable languages that use JIT compilation include language. There are not many the category of ahead-of-time or just- Java and C#. languages that have both types of in-time. A related third category is the compilers built, much less interpreter, which is not a compiler Comparison maintained. but has similarities to a just-in-time • My results represent neither a typical compiler. • In order to compare the two compilation methods, I nor an extraordinary usage of either compiled and ran a short program using both method. Both may perform better or methods. worse in other implementations. Ahead-of-Time Compilation • For my AOT compiler, I used Excelsior JET, a proprietary AOT Java compiler. • Ahead-of-time compilation (or AOT) • For my JIT compiler, I used the Java Standard Additional Work refers to the practice of running a Edition Runtime Environment (JRE). separate compilation command prior • To time the compilation of Excelsior JET, I used the to runtime, generating a separate file program’s internal compilation timer. To time the There is significant room for additional that is then executed by the compilation of the JRE and the execution of both, I work in this area. This work includes: computer. used the “time” command. • Comparisons using other • Programs that are compiled AOT • In order to account for threading on my multi-core programming languages. generate that is processor, I measured the timings several times • More thorough and varied tests, specific to one computer or type of and took the mean values. rather than a single program. computer. In order to be run on a • Robust automated testing. different computer, the original code AOT Run vs JIT Run AOT Compile vs JIT Compile and Run • Analysis of structures on which each 0.16 3.5 must be recompiled. method excels. 0.14 • Compiled code may be run on that 3

machine any number of times 0.12 2.5 without recompiling. References 0.1 • Programs that are compiled AOT 2 0.08

John Aycock. 2003. A brief history of just-in-time. ACM Comput. Surv. 35, 2 Time Time (seconds) tend to run faster than their just-in- Time (seconds) 1.5 (June 2003), 97-113. DOI=http://dx.doi.org/10.1145/857076.857077 time counterparts, since there is 0.06

1 Bucciarelli, Thiemo. "Just-In-Time Compilation." Universität Zu Lübeck. Web. more time available to optimize code. 0.04 V. Mikheev, N. Lipsky, D. Gurchenkov, P. Pavlov, V. Sukharev, A. Markov, S. • Notable languages that use AOT 0.5 0.02 Kuksenko, S. Fedoseev, D. Leskov, and A. Yeryomin. 2002. Overview of compilation include C, C++, and excelsior JET, a high performance alternative to java virtual machines. In

0 0 Proceedings of the 3rd international workshop on Software and performance Pascal. JET Run Java Run JET Compile Java Compile and Run (WOSP '02). ACM, New York, NY, USA, 104-113. DOI=http://dx.doi.org/10.1145/584369.584387