Scaling API-first – The story of a global engineering organization
Jit complier
1. COMPILER IN
JAVA
complier java use and effect on
performance
San Jose State University
Computer Science Department
2014 Fall
Kaya Ota
2. AGENDA
First of all CPU
Java attempt to do
Kinds of compilers
The difference of each complier
The reasons why Java has multiple compliers
3. 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
4. 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.
5. 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.
6. 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 compiler
dynamic
compiling
7. 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
8. 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
9. 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.
10. 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.
11. 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.
13. 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
14. 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
15. 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.
16. 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/