jit complier
TRANSCRIPT
COMPILER IN JAVAcomplier java use and effect on performance
San Jose State University Computer Science Department 2014 Fall
Kaya Ota
AGENDA
First of all CPU Java attempt to do Kinds of compilers The difference of each complier The reasons why Java has multiple compliers
FIRST OF ALL
Any computer (CPU) can execute only assembly or binary code
As well known, all programs must be translated into binary code.
CPU
Assembly or binary
Java, python, c, English,
Japanese, etc
WHAT JAVA ATTEMPT TO….
Compiled Language Benefit : once source
code is translated to binary, it does not have to re-translate. So, it will be faster than an interpreted language.
Downside : compiled languages are tightly coupled with CPU. So, programs do not have a portability.
Interpreted Language Benefit : if a computer
has a appropriate interpreter, then programs can run on the machine. (it is portable.)
Downside : an interpreter translate each line one by one, so it need to translate again and again. Therefore, it is slower than complied language.
Java tries to have portability AND speed of compiled language.
COMPILE ONCE & RUN EVERYWHERE To be independent from CPU and OS, java make the
process of compilation into two steps. 1st step : Source Code intermediate code (= .class)
So, only on JVM, an intermediate code is executable
2nd step : intermediate code binary This is still dependent on CPU and OS.
PROGRAM AT COMPILER TIME AND AT EXECUTION TIME SRC.java
Java compiler(javac [.java
file])
Java byte code .class
Class loader Byte code verifier
Byte code
source through new or
file system
JVM JIT
OS
hardware
1st step compiler
static compiling
2nd step compilerdynamic
compiling
JAVA HAS MULTIPLE KINDS OF COMPLIER Different applications have different needs.
Long run enterprise application allows more optimizations. Smaller client-side application needs fast execution with less resource consumption.
Client Compiler Server Compiler Tired Compilation
The primary difference between client compiler and server complier is their aggressiveness in compiling code
DIFFERENCE BETWEEN CLIENT AND SERVER
footPrint(memory usage)
Running time Warming up time
Client
Server
Time interval between download and activation of an
application once
CLIENT
The primary objective of the client compiler is “fast start up.”
The client complier begins compiling sooner than server complier does.
During the beginning of execution, the client compiler will be faster
Because the client compiler compiles more code correspondingly
Usually client has a fewer memory, so client compiler
is optimized in memory usage as shown in a
previous table.
SERVER
Server side applications are expected to run in a long period of time.
Instead of using more resources,( such as CPU cycles, larger code cache, etc) these applications delivers more advanced optimizations for later in running cycle.
TIERED COMPILATION
Tiered compilation combines the best parts of client side compilation and server side compilation.
Tiered compilation gather data during low-impact compiler activity.
To apply more advanced optimizations later, the compiler can use the data.
DEFAULT SETTING OF COMPILERS
Windows Mac
CHANGE YOUR COMPILER
Windows
Installer x86 for 32bit machine Java option: -client or –server (default client )
Installer x64 for 64bit machine Java option: -hotspot or –server (default server)
Mac 64 bit ---only for –server
HOT SPOT COMPLICATION
Hot spots of application : the more the section of the code is executed. the hotter that section is said to be.
Typically, some subset of codes are executed frequently. And, a performance of an application depends on the frequently
executed codes. So, java starts running an application with interpreter like and
determine which chunks of codes are invoked frequently Then, java decides to compile those chunks of codes(no longer
translate them again!) Benefit : by avoiding infrequently invoked codes, java complier can
focus on the performance-critical-parts, without necessarily increasing the overall compilation time
EXAMPLE OF HOT SPOT
Priority Queue insert(int newItem) delete(int position) increaseKey(int posi, int
delta) decreaseKey(int posi, int
delta)
shiftUp(int position) shiftDown(int position)
Those functions call shiftUp or shiftDown somewhere in their
procedure .
Therefore, shiftUp and shiftDown are said to be hotter than other
functions.
REFERENCE
JVM performance optimization http://www.javaworld.com/article/2078635/enterprise-middleware/jvm-
performance-optimization-part-2-compilers.html
Java Performance : The Definitive Guide by Scott Oaks Why Java Is Better Then Other Programming Language And
Byte Code Concept http://codemink.com/why-java-is-better-byte-code-concept/