A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation
description
Transcript of A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation
![Page 1: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/1.jpg)
A New Transpant JAVA Thread Migration System Using Just-in-
Time Recompilation
Wenzhang Zhu, Cho-Li Wang, Weijian Fang, and Francis C.M. Lau
The University of Hong Kong
![Page 2: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/2.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 2
Java Thread
Lightweight computation unit Supports concurrency Supported by Java at language level Shared memory paradigm Multithreading used in large Java programs –
e.g. Tomcat, JBoss
![Page 3: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/3.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 3
True Parallelism for Threads
Multiple threads of a program spreading over multiple compute nodes in a cluster
A “global object space” to support data sharing
JESSICA2 [8]
Heap Heap
threads
CPU1 CPU2 CPU3
objects
![Page 4: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/4.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 4
Dynamic Thread Migration
To achieve load balancing and best performance for applications
overloaded underloaded balanced workload
![Page 5: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/5.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 5
Example of Thread Migration
We need to carry the code and its execution state to remote node
What is in the execution state? At least
the program counter the intermediate
values of variables
i=1;j=2;
k=i+j;
Node 1
Node 2
Program:
1: i=1;
2: j=2;
3: k=i+j;
![Page 6: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/6.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 6
Previous Approaches
User level Bytecode level [6][7] JVM level [4][5], with JIT [9] Normal thread execution suffers
time: checking flags and flushing registers to memory space: code size expanded
A multithreaded Java application will have >95% normal execution, <5% migration
What we present will help optimize the 95%
![Page 7: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/7.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 7
JIT Compilation
Can we migrate native code? No, machines are not the same
Javabytecodeinexecution
JITC
Native code
Migrate?
![Page 8: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/8.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 8
New Approach
Derive portable bytecode-oriented thread context (BTC) from native (raw) thread context (RTC)
Restore BTC to RTC
Re-run JIT compilation in both phases to transform the thread context
Target nodeTarget node
Source nodeSource node
![Page 9: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/9.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 9
The Detailed Steps
Very quickly …
![Page 10: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/10.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 10
Just-in-Time Recompilation (source node)
Stack walk
main()
compute()
JVM-kernel function()
![Page 11: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/11.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 11
Just-in-Time Recompilation (source node)
Stack walk
Frame segmentation
main()
compute()
JVM-kernel function()
Javaframesto migrate
![Page 12: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/12.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 12
Just-in-Time Recompilation (source node)
Stack walk
Frame segmentation
main()
compute()Bytecode PC positioning
incl %ebx
cmpl $0x1e, %ebx
jl 0x82512432
iinc 1, 1
iload_1
bipush 30
if_icmplt 5Mapping
![Page 13: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/13.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 13
Just-in-Time Recompilation (source node)
Stack walk
Frame segmentationcompute()
Bytecode PC positioningincl %ebx
cmpl $0x1e, %ebx
jl 0x82512432
iinc 1, 1
iload_1
bipush 30
if_icmplt 5
Breakpoint selection
getstatic #2return
breakpoint
![Page 14: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/14.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 14
Just-in-Time Recompilation (source node)
Stack walk
Frame segmentationcompute()
Bytecode PC positioning
Breakpoint selection
Type derivation
local 0: java.lang.threadlocal 1: intstack 0: floatstack 1: int
main()
local 0: java.lang.threadstack 0: doublestack 2: double
![Page 15: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/15.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 15
Just-in-Time Recompilation (source node)
Stack walk
Frame segmentationcompute()
Bytecode PC positioning
Breakpoint selection
Type derivation
Translation
re-generate native code with breakpoints
getstatic #2Iload_1
inc %ebxcmpl $1e, %ebxjl 0x82512432
0x82512432:… capture frames…--- save local var’s and their typereturn
main()...other native code...jmp start_migration
![Page 16: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/16.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 16
Just-in-Time Recompilation (source node)
Stack walk
Frame segmentation compute()
Bytecode PC positioning
Breakpoint selection
Type derivation
Translation
replace saved return address with the newlygenerated code
inc %ebxcmpl $1e, %ebxjl 0x82512432
0x82512432:… capture frames…--- save local var’s and their typereturn main()
...other native code...jmp start_migration
Native code patching
saved return address
activation record ofcompute()
![Page 17: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/17.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 17
Just-in-Time Recompilation (target node)
Thread creation
Frame
PC
![Page 18: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/18.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 18
Just-in-Time Recompilation (target node)
Thread creation
Dynamic register patchingcompute()
1. use JIT compiler to derive register2. mapping at restoration point generate
code stub
Register recovering stub:movl %0x1234, %eaxmovl %0x5678, %ebx...
main()
Register recovering stub:movl %0x1111, %eax...
![Page 19: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/19.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 19
Just-in-Time Recompilation (target node)
Stack growth
%ebp
bootstrap frame
trampoline frame
Ret addr
frame 0
reg1 <- value1reg2 <- value2
jmp restore_point0
Ret addr
%ebp
%ebp
frame 1
reg1 <- value1jmp restore_point1
Compiled methods:
compute(){...retore_point1:}
main(){...retore_point10:}
trampoline
bootstrap(){ trampoline();closing handler();}
Stack rebuilding
Thread creation
Dynamic register patching
Linking code stub and native frames
![Page 20: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/20.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 20
Experimentation
Cluster of 2GHz P4 PCs, running Linux kernel 2.4.22
Normal runtime overhead = 0 Migration latency hiding
Pre-loading classes needed at target node when the frames have been segmented
Overlapping class loading with stack transform at source node
![Page 21: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/21.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 21
Migration Overhead
0
5000
10000
15000
20000
25000
30000
35000
40000
CPI SOR ASP NBody
Tim
e(u
s)
DNCI
JITR
JITR + Preload
0
5000
10000
15000
20000
25000
30000
35000
40000
CPI SOR ASP NBody
Tim
e(u
s)
DNCI
JITR
JITR + Preload
DNIC: Dynamic Native Code Instrumentation approachJITR: Just-in-Time recompilation approachJITR+Preload: Just-in-Time recompilation with class preloading enabled
![Page 22: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/22.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 22
Multithreaded Java Application Server Simulation
![Page 23: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/23.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 23
Parallel Mesh Refinement Simulation
![Page 24: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/24.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 24
Conclusion
This paper presents an efficient transparent Java thread migration system using the technique of JIT recompilation without code instrumentation
The idea of using JIT recompilation demonstrates a new use of the JIT compiler to gather runtime information
![Page 25: A New Transpant JAVA Thread Migration System Using Just-in-Time Recompilation](https://reader036.fdocuments.net/reader036/viewer/2022062321/56813fee550346895daaf353/html5/thumbnails/25.jpg)
10 Nov 2004 16th IASTED PDCS 2004, Cambridge, USA 25
JESSICA2 Website
www.csis.hku.hk/~clwang/projects/JESSICA2.html