jit complier

16
COMPILER IN JAVA complier java use and effect on performance San Jose State University Computer Science Department 2014 Fall Kaya Ota

Upload: kaya-ota

Post on 06-Aug-2015

62 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Jit complier

COMPILER IN JAVAcomplier java use and effect on performance

San Jose State University Computer Science Department 2014 Fall

Kaya Ota

Page 2: Jit complier

AGENDA

First of all CPU Java attempt to do Kinds of compilers The difference of each complier The reasons why Java has multiple compliers

Page 3: Jit complier

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

Page 4: Jit complier

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.

Page 5: Jit complier

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.

Page 6: Jit complier

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

Page 7: Jit complier

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

Page 8: Jit complier

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

Page 9: Jit complier

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.

Page 10: Jit complier

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.

Page 11: Jit complier

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.

Page 12: Jit complier

DEFAULT SETTING OF COMPILERS

Windows Mac

Page 13: Jit complier

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

Page 14: Jit complier

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

Page 15: Jit complier

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.

Page 16: Jit complier

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/