expresso speedup prediction for selective compilation of embedded java programs "workshop on...

32
EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002. LNCS 2491. V. Colin de Verdiere, S. Cros, C. Fabre, R. Guider Silicomp Research Institute S. Yovine Verimag

Upload: estelle-olivier

Post on 03-Apr-2015

114 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

Speedup Prediction for Selective Compilation of Embedded Java Programs

"Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002. LNCS 2491.

V. Colin de Verdiere, S. Cros, C. Fabre, R. Guider

Silicomp Research InstituteS. Yovine

Verimag

Page 2: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

Analyse du Byte-code Java par instrumentation :

amélioration des performances par compilation sélective

Sébastien Cros

Mémoire d’Ingénieur C.N.A.M. en Informatique Grenoble, 2 juillet 2002

Travaux réalisés du 1er Février 2001 au 31 Janvier 2002 au sein de l’équipe compilation du Silicomp Research Institute, sous la direction de M. Sergio Yovine du laboratoire VERIMAG.

Page 3: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

3

(c) Sergio Yovine - VERIMAG - [email protected]

Plan de la présentation

• Projet Expresso – Java pour l’embarqué

Page 4: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

4

(c) Sergio Yovine - VERIMAG - [email protected]

Java

GarbageCollector

Java NativeInterface

Scheduler

Data Area Thread Area

Interpreter

Operating System

JVM

Page 5: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

5

(c) Sergio Yovine - VERIMAG - [email protected]

Java embarqué

MemoryAllocation

Java NativeInterface Synthesized

Scheduler

Data Area Thread Area

Native code

Real Time Operating System

JRTS

Page 6: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

6

(c) Sergio Yovine - VERIMAG - [email protected]

Expresso

Page 7: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

7

(c) Sergio Yovine - VERIMAG - [email protected]

Plan de la présentation

• Projet Expresso – Java pour l’embarqué• Génération de code natif – prédiction de l’accélération

Page 8: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

8

(c) Sergio Yovine - VERIMAG - [email protected]

Génération de code natif

« à la volée » - JIT

• Optimisations plus importantes• Conserve le code compilé.

« statique » - AOT

• Utilisation de ressourcesCPU & RAM• Recompile à chaque exécution

• Sacrifie la portabilité

• Compilation du code résident et chargé

Ava

nta

ges

Inco

nvé

nie

nts

Expansion de la taille du code compilé

Page 9: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

9

(c) Sergio Yovine - VERIMAG - [email protected]

TurboJ

• Compilateur java AOT• Du bytecode vers le code natif.• Utilisation du C comme langage intermédiaire.• Compile une fois, conserve le code compilé.• Optimisations globales.• Cohabitation du bytecode et du code natif à l’exécution

(exécution mixte).• Compilation sélective par méthode.

Page 10: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

10

(c) Sergio Yovine - VERIMAG - [email protected]

Compilation sélective

TurboJInstrumentationde l ’application

.classInformationscollectées

Exécutiontypique Analyse

Byte-codeInstrumenté

Analyse de l ’application Compilation

Applicationcompilée

Liste desméthodesà compiler

Page 11: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

11

(c) Sergio Yovine - VERIMAG - [email protected]

Hypothèses : • Accélération constante quelque soit le type de Byte-code

compilé.• Nombre de Byte-codes exécutés par une méthode reflète son

temps d ’exécution.

Technique naïve de partitionnement

Sélectionner les méthodes qui exécutent le plus grand nombre de Byte-code.

Page 12: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

12

(c) Sergio Yovine - VERIMAG - [email protected]

Sélection des méthodes triées sur le nombre de Byte-codes exécutés.

Nb

de

Byt

e-c

od

es

exé

cuté

s

méthodes1

Sélection

2 3 4

Peut-on prédire l’accélération ?

Page 13: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

13

(c) Sergio Yovine - VERIMAG - [email protected]

Page 14: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

14

(c) Sergio Yovine - VERIMAG - [email protected]

Plan de la présentation

• Projet Expresso – Java pour l’embarqué• Génération de code natif• Prédiction de l’accélération

Page 15: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

15

(c) Sergio Yovine - VERIMAG - [email protected]

manipulation pile, branchement,variables (locales, d ’instances, classes),arithmétique, convertion de type

new, newarray, anewarray, multianewarray, athrow, checkcast, instanceof, moniterenter, moniterexit

Invokevirtual, invokeinterface, invokestatic, invokespecial

Type de Byte-code

« Appels de

méthodes »

Accélération

« Forte interaction avec la

machine virtuelle »

« Calcul »

Catégorie de Byte-code

importante

faible

variable

Classification du Byte-code

Page 16: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

16

(c) Sergio Yovine - VERIMAG - [email protected]

Appel croisé

Appel entre une méthode compilée et une méthode interprétée ou native.

a

b

d

Interprétée

Native

compilée

c

Appel Direct

compilée

méthode

e

Interprétée

Appel Croisé

Page 17: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

17

(c) Sergio Yovine - VERIMAG - [email protected]

Coût des appels

Méthode Appelante / Appelée

invokevirtual

invokeinterface

invokestatic

Int / Int Int / Cpl Cpl / Int Cpl / Cpl

1

1

1

0.3

0.5

0.4

0.6

0.6

0.6

5

2.5

5

Appels croisés Appels directs

invokespecial 1 0.4 0.5 5

Accélération

Page 18: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

18

(c) Sergio Yovine - VERIMAG - [email protected]

Page 19: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

19

(c) Sergio Yovine - VERIMAG - [email protected]

Modèle d ’accélération

Byte-codes exécutés

Appels croisés

Nb Byte-codes exécutés compilés

Nb appels croisésR =

Page 20: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

20

(c) Sergio Yovine - VERIMAG - [email protected]

Page 21: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

21

(c) Sergio Yovine - VERIMAG - [email protected]

Plan de la présentation

• Projet Expresso – Java pour l’embarqué• Génération de code natif• Prédiction de l’accélération• Mise en œuvre

Page 22: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

22

(c) Sergio Yovine - VERIMAG - [email protected]

Compilation sélective

TurboJInstrumentationde l ’application

.classInformationscollectées

Exécutiontypique Analyse

Byte-codeInstrumenté

Analyse de l ’application Compilation

Applicationcompilée

Liste desméthodesà compiler

Page 23: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

23

(c) Sergio Yovine - VERIMAG - [email protected]

Graphe d ’appels

T.j()

C.m() D.m()A.m()

8

510

1537

Page 24: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

24

(c) Sergio Yovine - VERIMAG - [email protected]

Appels de méthodes

invokespecial et invokestatic=> Une méthode cible unique.

invokevirtual et invokeinterface=> Polymorphisme : Plusieurs cibles

potentielles.

Page 25: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

25

(c) Sergio Yovine - VERIMAG - [email protected]

public Int getId(){ return 0;}

public Int getId(){ return 1;}

public Int getId(){ return 2;}

public Int getId(){ return 3;}

Cibles potentielles

T.j()Invokevirtual A.toString()V

?.m()

Class A {public String m(){...}

}Class B extends A {

}Class C extends B {

public String m(){...}

}Class D extends B {

public String m(){...}

}

Invokevirtual A.getId()I

T.j()

C.m() D.m()A.m()

Page 26: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

26

(c) Sergio Yovine - VERIMAG - [email protected]

Techniques mises en œuvre

• Analyse de la hiérarchie de classes=> retrouver les cibles potentielles de chaque point d ’appels.

• Parcours du flot d ’exécution=> retrouver la référence d ’un objet sur la pile d ’opérande.

• Analyse de type intra-procédurale=> réduire le nombre de compteurs d ’appels.

Page 27: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

27

(c) Sergio Yovine - VERIMAG - [email protected]

Compilation sélective

TurboJInstrumentationde l ’application

.classInformationscollectées

Exécutiontypique Analyse

Byte-codeInstrumenté

Analyse de l ’application Compilation

Applicationcompilée

Liste desméthodesà compiler

Page 28: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

28

(c) Sergio Yovine - VERIMAG - [email protected]

Algorithme glouton

c

d e

f

a

b

c

d e

fg g

a

b

Ens. des méthodes sélectionnées

Ens. des méthodes candidates

Évaluation du ratiopour chaque candidats

Sélection du candidatmaximisant le ratio

1

10 50

1

50

5

1

10 50

1

50

5

Page 29: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

29

(c) Sergio Yovine - VERIMAG - [email protected]

Page 30: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

30

(c) Sergio Yovine - VERIMAG - [email protected]

Résultats

Page 31: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

31

(c) Sergio Yovine - VERIMAG - [email protected]

Conclusions

• Outil: 13000 lignes de Java, 80 classes– d ’instrumentation « Tprofiler » : Collecte le graphe d ’appels– Outil d ’analyse « Tselect » : Heuristique gloutonne

• Axes d’évolution :– Analyse : sélection initiale des méthodes – Modèle : raffiner la classification du Byte-code

Page 32: EXPRESSO Speedup Prediction for Selective Compilation of Embedded Java Programs "Workshop on Embedded Software, EMSOFT'02". Grenoble, October 7-9, 2002

EXPRESSO

32

(c) Sergio Yovine - VERIMAG - [email protected]