emsoft’02 silicomp research institute jcod 1 jcod a lightweight modular compilation technology for...

19
EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD JCOD A Lightweight Modular Compilation A Lightweight Modular Compilation Technology For Embedded Java Technology For Embedded Java Bertrand Delsart : [email protected] Vania Joloboff : [email protected] Eric Paire : [email protected] Silicomp Research Institute

Upload: joan-jenkins

Post on 31-Dec-2015

216 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 1

JCODJCOD

A Lightweight Modular Compilation Technology A Lightweight Modular Compilation Technology For Embedded JavaFor Embedded Java

Bertrand Delsart : [email protected]

Vania Joloboff : [email protected]

Eric Paire : [email protected]

Silicomp Research Institute

Page 2: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 2

PlanPlan

• Java and JIT compilers

• JCOD solution

• Dynamic profiling

• Experimental results

Page 3: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 3

JavaJava

• Advantages– Productivity gain (GC, object oriented)– Portability (CPU + OS)– Mobility (dynamic loading, security…)– Code size

• Drawback– Performance

Page 4: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 4

Improving performanceImproving performance

• Use native methods for the critical parts• Generate optimized bytecode • Replace the interpreter by a dedicated hardware• Transform the bytecode into native code

– before installation : Ahead Of Timeand / or– during execution : Just In Time

SRI works on both compilation techniques

Page 5: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 5

Just In Time compilersJust In Time compilers

Compile the byte code just before its first execution

• Advantage– Preservation of dynamic loading and mobility

• Drawbacks– Compilation delay– Compilation resources– Code size expansion

Page 6: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 6

JCOD solutionJCOD solution

• Compilation delay start in interpreted mode

• Compilation resources compile on a remote compilation server

• Code size expansion optimize the compiled code size select the best compilation candidates

Java Compilation On Demand

Page 7: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 7

Remote mechanismRemote mechanism

• Support JVM independent compilers • Use a downloadable JVM dependent plug-in• Already handle :

– remote administration– remote debugging– reconnection

100 % Java• Extensions : secure protocol, code mobility …

Page 8: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 8

Code size optimizationsCode size optimizations

• Favor code size over performance• Use a library for complex bytecodes (64 bits,

lookupswitch, tableswitch…)• Share prelude and postlude (synchronization,

call traces, stack handling, …)• Share wrappers for external calls (exception

delivery, call backs, …)• …

Page 9: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 9

Method selectionMethod selection

• At least test several policies during our research

• If possible after deployment, allow– other policies by third parties– tailoring of the policy for a kind application or platform

flexible, programmable but efficient policies

Page 10: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 10

Profiling Java objetProfiling Java objet

– Profiling information efficiently gathered for one or more methods

– Notification mechanism for some events (enter, exit, “interesting method” …)

• Programmable notification listeners

• Flexible notification policy

Page 11: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 11

Decision Maker (in Java)Decision Maker (in Java)

• Control the profiling mechanism– Associate interpreted methods with a profiling object– Select the notification policy of each profiling object

• Handle the profiling information– Asynchronously parse the profiling objects– Provide the notifications listeners for each kind of

profiling object

Page 12: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 12

Example of policiesExample of policies

• Cruise mode select a method only when interpreting more than X bytecode/s

• Exit sampling “promote” the Nth executed method, or the current method when the

interpreter has parsed X bytecodes

• Asynchronous focused profiling1) starts with a single profiling object2) allocate a methodData for “interesting” methods

3) asynchronously select the best profiling object

Page 13: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 13

Cost of method callsCost of method calls

callee

caller

interpreted compiled

interpreted 1 2.5

compiled 1.8 0.2x10

Page 14: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 14

Lion’s share ruleLion’s share rule

90% of the time is spent in 10% of the code

Compile the “hotspots”– bytecode inside a loop– methods called often (…by a loop)

But detect them without a per method history to reduce the memory consumption

rely on cross calls to identify method called often

Page 15: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 15

Profiling information and notifiersProfiling information and notifiers

• increase the considered set thanks to data in a global profiling object (efficiently updated on method exit) :– number of interaction with compiled methods– interpretation cost due to loops– interpretation cost (for sampling, …)– number of execution (for sampling, …)

• decide thanks to per method profiling object and : – global interpretation cost (to detect the cruise mode, …)– number of interaction with interpreted methods (to avoid cross

calls)

• the notifiers receives the caller ID to let complex decision maker build a call graph

Page 16: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 16

NotifiersNotifiers

• Global interpretation cost overflow• Exit notifier :

– methodData interpretation cost overflow– After the Nth executions :

• NOTIFY_EXIT_ALL_METHODS• NOTIFY_EXIT_ON_CROSSCALL• NOTIFY_EXIT_ON_LOOP

• (Enter notifier)

Page 17: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 17

Experimental results : overheadExperimental results : overhead

• Small support code in ROM on the VM ( 20 K)• Negligible CPU profiling overhead• Small memory overhead for profiling information

thanks to the focusing techniques• Small memory overhead for the compiled code

• Huge compilation delay due to the remote features … but not critical since compilation is asynchronous

Page 18: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 18

Experimental results : efficiencyExperimental results : efficiency

• Taking the worst case for the compiler :– Acceleration factor : x4– Code size expansion : x3

• And the lion’s share rule (90% CPU in 10% code)– Performance : x3

(100s 10 + (90 / 4) = 32.5s)

– Memory : x1.2(100K 90 + (10 x 3) = 120K)

Page 19: EMSOFT’02 Silicomp Research Institute JCOD 1 JCOD A Lightweight Modular Compilation Technology For Embedded Java Bertrand Delsart : b.delsart@ri.silicomp.fr

EMSOFT’02 Silicomp Research Institute JCOD 19

ConclusionConclusion

• Efficient profiling• Low cost solution• Portable and extensible

– JVM independent compiler in Java– CPU independent JVM resolver in Java– High level profiling in Java

Already repackaged to work in AOT mode !