IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement...

24
IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008

Transcript of IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement...

Page 1: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

AOT Compilation in a Dynamic Environment for Startup Time Improvement

Kenneth Ma

Marius Pirvu

Oct. 30, 2008

Page 2: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Outline

• Background• Functional Challenges• Performance Results• Performance Challenges• Future Work• Conclusions

Page 3: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Motivation

• Improve startup time– Server applications: WebSphere Application Server,

WebSphere Process Server, Tomcat– Development tools: Eclipse, Rational Application Developer,

WebSphere Integration Developer• Improve response time

– Especially for GUI applications• Improve CPU utilization

– Important for zOS

Page 4: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Shared Classes in Java 6 IBM SDK

• Store classes into a cache that can be shared by multiple JVMs

• Reduces memory footprint• Improves startup time• Many new features including:

– Prevention of cache corruption– Class compression– Persistent cache– Cache AOT code

Page 5: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

How shared classes works

Shared Cache1

Classes on disk

JVM1

JVM2

Shared Cache2

JVM3

JVM4

Classes

Classes

Page 6: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Ahead-Of-Time (AOT) Compilation

• What is AOT?– Native compiled code generated “ahead-of-time” to be used

by a subsequent execution– Persisted into the shared cache

• Why AOT?

– Improve startup time– Reduce CPU utilization

Page 7: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Shared Cache1

How AOT works

Shared Cache2

Classes on disk

JVM1

JVM2

JVM3

JVM4

Classes

AOTCode

Classes

AOTCode

Page 8: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

AOT in Java 6 IBM SDK

• Cross platform support– Supported on all IBM JSE platforms, including S390,

PowerPC, and X86– 32-bit and 64-bit support– Compressed pointer support starting in SR1

• Compatibility checking– Processor specific– GC policy– Compressed pointer

Page 9: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Functional Challenges

• Static vs Dynamic AOT population– Compiling select methods– Platform neutrality

• Multi-platform support– Porting AOT functionality to all the major platforms– 64-bit support

• E.g. PPC 64-bit, load address values using sequences of instructions instead of 1 load instruction

• Footprint reduction– Reduce redundancies and pull in only relevant information

• E.g. Sharing “j2i thunks”

Page 10: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Functional Challenges

• Increase possible combinations by many factors– Checking all configurations working properly more difficult– Test framework change

• AOT runtime vs compile time– Runtime state different from compile time

• E.g. Alignment differences

Page 11: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Performance Goals

Two main classes of applications:1. Server applications (e.g. WebSphere, tomcat)

• Goals:– Fast restart after software reconfiguration/update– Fast cold restart (after machine reboot)– CPU utilization reduction (important on zOS)– No degradation in throughput

2. Desktop/client applications (e.g. eclipse, WID)• Goals:

– GUI applications should feel responsive– Fast restart during development cycle– Fast cold restart after machine shutdown

Page 12: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Performance of Server Applications

• 9-25% startup time improvement from AOT code

Startup Time of Server Applications

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

X86 PPC s390 X86 PPC s390

WAS 6.1 Tomcat 5.5.20

No

rmal

ized

tim

e

NoSharedClasses

SharedClasses noAOT

SharedClasses +AOT

Page 13: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Performance of Server Applications

CPU Time for Server Applications

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

X86 PPC s390 X86 PPC s390

WAS 6.1 Tomcat 5.5.20

No

rma

lize

d t

ime

NoSharedClasses

SharedClasses noAOT

SharedClasses +AOT

Page 14: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Performance of Server Applications

CPU Time for Server Applications on zOS

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

X86 PPC s390 X86 PPC s390

WAS 6.1 Tomcat 5.5.20

No

rmali

zed

tim

e

NoSharedClasses

SharedClasses noAOT

SharedClasses +AOT

• 26-29% reduction in CPU cycles on zOS due to AOT

Page 15: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Performance of Desktop Applications

• 8-15% startup time improvement from AOT code

Startup Time of Desktop Applications-Xquickstart

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

Eclipse 3.3.2 WID 6.1

No

rmal

ized

tim

e

NoSharedClasses

SharedClasses noAOT

SharedClasses +AOT

Page 16: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Cold Restart

• Persistency 20-50% startup time improvement for cold restarts

Effect of AOT shared classes on startup time (cold start - after a reboot)

0

0.2

0.4

0.6

0.8

1

1.2

WAS 6.1 Tomcat 5.5.20 Eclipse 3.3.2 WID 6.1

No

rmal

ized

tim

e

No shared class cache

Non-persistent cache

Persistent cache

Page 17: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Performance Challenges

• Throughput/startup-time dilemma • Improve runtime performance/throughput

heavily optimize code– More optimization passes– More complex optimizations

• Shorter startup time make compiled code available as early as possible– Compile fast use cheap optimizations– Compile only what matters

• A real challenge to satisfy both desiderates

Page 18: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Performance Challenges

• AOT code quality lower than JIT code quality– No inlining– Treat everything as unresolved– Oblivious of class hierarchy

• Concern: extensive use of AOT code might degrade throughput of server applications– Questions:

• When to generate/store AOT code• When to use/load AOT code

Page 19: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Performance Challenges

• When to generate/store AOT code?– Always

• Throughput may degrade (5-10% loss on DayTrader)• Used for -Xquickstart

– During startup phases• Class load phase heuristic

• When to use/load AOT code?– Always

Page 20: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Performance Challenges

• Steps to avoid a potential throughput loss– Filter methods to be AOT-ed– First run detection– Aggressive recompilation of AOT code (upgrade)

Page 21: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Effect of AOT Code on Throughput

• Throughput loss is under 2%

Throughput of DayTrader J2EE Application (on top of WAS 6.1)

0.5

0.55

0.6

0.65

0.7

0.75

0.8

0.85

0.9

0.95

1

X86 PPC s390

No

rmal

ized

Th

rou

gh

pu

t

SharedClasses noAOT

SharedClasses +AOT

Page 22: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Performance Challenges

• How to minimize startup time– Use AOT code sooner (but not too soon )– Give higher priority to relocation requests (shortest job first

policy)• Minimize overhead

– Reduce the overhead to search the shared cache– Reduce the number of shared cache searches– Turn off interpreter profiling if JIT code not used

Page 23: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Future Work

• Improve quality of AOT code

• Generate AOT code more aggressively and change the mechanism of upgrading AOT compilations

• Store additional information about compiled methods

Page 24: IBM JIT Compilation Technology AOT Compilation in a Dynamic Environment for Startup Time Improvement Kenneth Ma Marius Pirvu Oct. 30, 2008.

IBM JIT Compilation Technology

Conclusions

• AOT code technology available in Java 6 on all IBM JSE supported platforms

• Many functional and performance challenges

• Good startup improvements on a wide range of platforms and applications