Trace Granularity Trace-granularity JIT Most common model for low-level code migration systems Interprets with profiling to identify hot execution paths Compiled fragments chained together in translation cache Strengths Only hottest of hot code is compiled, minimizing memory usage Tight integration with interpreter allows focus on common cases Very rapid return of performance boost once hotness detected Weaknesses Smaller optimization window limits peak gain More frequent state synchronization with interpreter Difficult to share translation cache across processes 8ĩ Hot vs.
Trace Granularity Method-granularity JIT Most common model for server JITs Interprets with profiling to detect hot methods Compile & optimize method-sized chunks Strengths Larger optimization window Machine state sync with interpreter only at method call boundaries Weaknesses Cold code within hot methods gets compiled Much higher memory usage during compilation & optimization Longer delay between the point at which a method goes hot and the point that a compiled and optimized method delivers benefits 7Ĩ Method vs.
Method Granularity JITs Dalvik JIT 1.0 Future directions for the JIT Performance Case Studies Profiling JIT d code Built-in Self-Verification Mode 3Ĥ Dalvik Execution Environment Virtual Machine for Android Apps See 2008 Google IO talk Very compact representation Emphasis on code/data sharing to reduce memory usage Process container sandboxes for security 4ĥ Dalvik Interpreter Dalvik programs consist of byte code, processed by a hostspecific interpreter Highly-tuned, very fast interpreter (2x similar) Typically less than 1/3rd of time spent in the interpreter OS and performance-critical library code natively compiled Good enough for most applications Performance a problem for compute-intensive applications Partial solution was the release of the Android Native Development Kit, which allows Dalvik applications to call out to statically-compiled methods Other part of the solution is a Just-In-Time Compiler Translates byte code to optimized native code at run time 5Ħ A JIT for Dalvik - but what flavor of JIT? Surprisingly wide variety of JIT styles When to compile install time, launch time, method invoke time, instruction fetch time What to compile whole program, shared library, page, method, trace, single instruction Each combination has strengths & weaknesses - key for us was to meet the needs of a mobile, battery-powered Android device Minimal additional memory usage Coexist with Dalvik s container-based security model Quick delivery of performance boost Smooth transition between interpretation & compiled code 6ħ Method vs. 2 A JIT Compiler for Android s Dalvik VM Ben Cheng, Bill Buzbee May 2010ģ Overview View live session notes and ask questions on Google Wave: Dalvik Environment Trace vs.