+ All Categories
Home > Documents > Run-time Evaluation of Opportunities for Object Inlining ...

Run-time Evaluation of Opportunities for Object Inlining ...

Date post: 19-Feb-2022
Category:
Upload: others
View: 4 times
Download: 0 times
Share this document with a friend
30
Run-time Evaluation of Opportunities for Object Inlining in Java Ond ˇ rej Lhot ´ ak and Laurie Hendren Sable Research Group McGill University November 5th, 2002 – p. 1/30
Transcript

Run-time Evaluation ofOpportunities for Object

Inlining in JavaOndrej Lhotak and Laurie Hendren

Sable Research GroupMcGill University

November 5th, 2002

– p. 1/30

Motivation

Java allows only references to objects asfields, not the objects themselves.

Object Inlining has been studied as a methodto implement languages with this restrictionefficiently.

ComplexPairxy

Complexre

im

Complexre

im

ComplexPairx_re

x_imy_re

y_im

– p. 2/30

Motivation

Java allows only references to objects asfields, not the objects themselves.

Object Inlining has been studied as a methodto implement languages with this restrictionefficiently.

How would Object Inlining affecttypical Java programs?

– p. 3/30

Contributions

Classification scheme for fields according tohow they can be inlined.

Empirical limit study of the potential effects ofobject inlining (upper bound on improvementsachievable by object inlining optimization).

Technique for determining which inlinablefields are important to optimize — could beuseful to programmers.

Observation of complex interactions betweenobject inlining and other optimizations: effectof “pointer chasing” is minor in comparison.

– p. 4/30

Outline

Object Inlining and Related Work

Definitions

Experiments and Results

Conclusion and Future Work

– p. 5/30

Object Inlining

class Complex

double re, im;

class NormFinder

Complex z;

double normSq()

returnz.re*z.re +z.im*z.im;

NormFinderz

Complexre

im

– p. 6/30

Object Inlining

class Complex

double re, im;

class NormFinder

Complex z;double z re, z im;double normSq()

returnz.re*z.re +z.im*z.im;

NormFinderzz_re

z_imComplex

re

im

– p. 7/30

Object Inlining

class Complex

double re, im;

class NormFinder

Complex z;double z re, z im;double normSq()

returnz re*z re +z im*z im;

NormFinderzz_re

z_imComplex

re

im

– p. 8/30

Object Inlining

class Complex

double re, im;

class NormFinder

Complex z;double z re, z im;double normSq()

returnz re*z re +z im*z im;

NormFinderzz_re

z_imComplex

re

im

– p. 9/30

Related Work

Dolby, Chien.PLDI ’97. Automatic Inline Allocation ofObjects.OOPSLA ’98. An Evaluation of AutomaticObject Inline Allocation Techniques.PLDI ’00. An Automatic Object InliningOptimization and its Evaluation.

Laud.JOSES ’01 (ETAPS). Analysis for ObjectInlining in Java.

– p. 10/30

Related Work

Ghemawat, Randall, Scales.PLDI ’00. Field Analysis: Getting Usefuland Low-Cost Interprocedural Information.

Budimlic.Ph.D. thesis, 2001. Compiling Java forHigh Performance and the Internet.

– p. 11/30

Predicates

[contains-unique] Every container having frefers to only one contained object through f.

p.f = c;p.f = d;

d

p

c

ff

– p. 12/30

Predicates

[unique-container-same-field] No objectstored into field f is stored into field f of anyother container.

p.f = c;r.f = c;

r p

c

ff

– p. 13/30

Predicates

[unique-container-different-field] No objectstored into field f is stored into any field g ofany other container.

p.f = c;q.g = c;

q

p

c

fg

– p. 14/30

Predicates

[not-globally-reachable] No object containedin f is ever stored into an array or static field.

p.f = c;Class.g = c;

a[i] = c;

Global

p

c

f

– p. 15/30

Field Classification

[contains-unique][unique-container-same-field]

[unique-container-different-field][not-globally-reachable]

Field-sensitive All 4 predicates Unique-storeone-to-one Simply[Dolby, Chien] one-to-one [Laud]

Move fields to container Copy fields to containerRemove contained Keep containedobject object

– p. 16/30

Field Classification

[contains-unique][unique-container-same-field]

[unique-container-different-field][not-globally-reachable]

Field-sensitive All 4 predicates Unique-storeone-to-one Simply[Dolby, Chien] one-to-one [Laud]

Move fields to container Copy fields to containerRemove contained Keep containedobject object

– p. 17/30

Field Classification

[contains-unique][unique-container-same-field]

[unique-container-different-field][not-globally-reachable]

Field-sensitive All 4 predicates Unique-storeone-to-one Simply[Dolby, Chien] one-to-one [Laud]

Move fields to container Copy fields to containerRemove contained Keep containedobject object

– p. 18/30

Field Classification

[contains-unique][unique-container-same-field]

[unique-container-different-field][not-globally-reachable]

Field-sensitive All 4 predicates Unique-storeone-to-one Simply[Dolby, Chien] one-to-one [Laud]

Move fields to container Copy fields to containerRemove contained Keep containedobject object

– p. 19/30

Experiments

Instrument benchmarks using Soot to recordgetfield, putfield, putstatic and aastore.

For each field, look for violations of eachpredicate in the traces.

eg....

p.f = c;...

p.f = d;...

� [contains-unique](f)

– p. 20/30

Experiments

Instrument benchmarks using Soot to recordgetfield, putfield, putstatic and aastore.

For each field, look for violations of eachpredicate in the traces.

eg....

p.f = c;...

q.f = c;...

� [unique-container-same-field](f)

– p. 21/30

Benchmarks

compress javasrc-p (Java to HTML)

db kawa-c (Scheme compiler)

jack rhino-a (Javascript interp.)

javac sablecc-j (Parser generator)

jess sablecc-wmpegaudio schroeder-m (Audio editor)

mtrt schroeder-sraytrace soot-c (Bytecode optimizer)

toba-s (Java native compiler)

– p. 22/30

Fraction of Field Reads Inlinable

0

20

40

60

80

100

compressdb

jack

javacjessmpegaudio

mtrtraytrace

javasrc-p

kawa-crhino-a

sablecc-j

sablecc-wschroeder-m

schroeder-s

soot-ctoba-s

Per

cent

Field-spec. one-to-one Unique-store Simply one-to-one

– p. 23/30

How Many Inlinable Fields are Important?

Fields accounting for 90% of inlinable field reads

compress 6 javasrc-p 6db 1 kawa-c 20jack 7 rhino-a 3javac 8 sablecc-j 12jess 5 sablecc-w 8mpegaudio 4 schroeder-m 4mtrt 5 schroeder-s 4raytrace 5 soot-c 20

toba-s 6

– p. 24/30

Inlinable Field Reads per Second

0

200000

400000

600000

800000

1e+06

compressdb

jack

javacjessmpegaudio

mtrtraytrace

javasrc-p

kawa-crhino-a

sablecc-j

sablecc-wschroeder-m

schroeder-s

soot-ctoba-s

Num

ber

of r

eads

per

sec

ond

8.3e+06

Field-spec. one-to-one Unique-store Simply one-to-one

– p. 25/30

Speedup from Hand-Inlining

compressSpeedup 7.8% to 10.8%

dbSpeedup up to 10.6% from one field

javasrc-pNo significant change

– p. 26/30

Loop Invariant Hoisting

Fields satisfying [contains-unique] predicateare loop invariant.

Hoisting loop invariants should give similarbenefit.

In compress, benefit from loop invarianthoisting is about half the benefit of objectinlining.

– p. 27/30

Bytes of Allocations Saved

0

2

4

6

8

10

compressdb

jack

javacjessmpegaudio

mtrtraytrace

javasrc-p

kawa-crhino-a

sablecc-j

sablecc-wschroeder-m

schroeder-s

soot-ctoba-s

Per

cent

Field-spec. one-to-one Simply one-to-one

– p. 28/30

Object Allocations Saved

0

5

10

15

20

25

compressdb

jack

javacjessmpegaudio

mtrtraytrace

javasrc-p

kawa-crhino-a

sablecc-j

sablecc-wschroeder-m

schroeder-s

soot-ctoba-s

Per

cent

Field-spec. one-to-one Simply one-to-one

– p. 29/30

Conclusions

Object inlining can produce speedups of upto 10%, but highly dependent on individualbenchmark.

Complex interactions with otheroptimizations; cost of “pointer chasing”insignificant in comparison.

Inlining field-specific one-to-one fields canyield savings of up to 7% of bytes, 21.6% ofobjects allocated.

Small number of fields are importantcould be hand-optimized.

– p. 30/30


Recommended