Run-time Evaluation of Opportunities for Object Inlining in Java - - PowerPoint PPT Presentation

run time evaluation of opportunities for object inlining
SMART_READER_LITE
LIVE PREVIEW

Run-time Evaluation of Opportunities for Object Inlining in Java - - PowerPoint PPT Presentation

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 Motivation Java allows only references to objects as fields,


slide-1
SLIDE 1

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

slide-2
SLIDE 2

Motivation Java allows only references to objects as fields, not the objects themselves. Object Inlining has been studied as a method to implement languages with this restriction efficiently.

ComplexPair x y Complex re im Complex re im ComplexPair x_re x_im y_re y_im

– p. 2/30

slide-3
SLIDE 3

Motivation Java allows only references to objects as fields, not the objects themselves. Object Inlining has been studied as a method to implement languages with this restriction efficiently.

How would Object Inlining affect typical Java programs?

– p. 3/30

slide-4
SLIDE 4

Contributions Classification scheme for fields according to how they can be inlined. Empirical limit study of the potential effects of

  • bject inlining (upper bound on improvements

achievable by object inlining optimization). Technique for determining which inlinable fields are important to optimize — could be useful to programmers. Observation of complex interactions between

  • bject inlining and other optimizations: effect
  • f “pointer chasing” is minor in comparison.

– p. 4/30

slide-5
SLIDE 5

Outline Object Inlining and Related Work Definitions Experiments and Results Conclusion and Future Work

– p. 5/30

slide-6
SLIDE 6

Object Inlining

class Complex

  • double re, im;

class NormFinder

  • Complex z;

double normSq()

  • return

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

✁ ✁

NormFinder z Complex re im

– p. 6/30

slide-7
SLIDE 7

Object Inlining

class Complex

  • double re, im;

class NormFinder

  • Complex z;

double z re, z im; double normSq()

  • return

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

✁ ✁

NormFinder z z_re z_im Complex re im

– p. 7/30

slide-8
SLIDE 8

Object Inlining

class Complex

  • double re, im;

class NormFinder

  • Complex z;

double z re, z im; double normSq()

  • return

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

✁ ✁

NormFinder z z_re z_im Complex re im

– p. 8/30

slide-9
SLIDE 9

Object Inlining

class Complex

  • double re, im;

class NormFinder

  • Complex z;

double z re, z im; double normSq()

  • return

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

✁ ✁

NormFinder z z_re z_im Complex re im

– p. 9/30

slide-10
SLIDE 10

Related Work Dolby, Chien. PLDI ’97. Automatic Inline Allocation of Objects. OOPSLA ’98. An Evaluation of Automatic Object Inline Allocation Techniques. PLDI ’00. An Automatic Object Inlining Optimization and its Evaluation. Laud. JOSES ’01 (ETAPS). Analysis for Object Inlining in Java.

– p. 10/30

slide-11
SLIDE 11

Related Work Ghemawat, Randall, Scales. PLDI ’00. Field Analysis: Getting Useful and Low-Cost Interprocedural Information. Budimli´ c. Ph.D. thesis, 2001. Compiling Java for High Performance and the Internet.

– p. 11/30

slide-12
SLIDE 12

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

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

d p c f f

– p. 12/30

slide-13
SLIDE 13

Predicates [unique-container-same-field] No object stored into field f is stored into field f of any

  • ther container.

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

r p c f f

– p. 13/30

slide-14
SLIDE 14

Predicates [unique-container-different-field] No object stored into field f is stored into any field g of any other container.

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

q p c f g

– p. 14/30

slide-15
SLIDE 15

Predicates [not-globally-reachable] No object contained in 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

slide-16
SLIDE 16

Field Classification [contains-unique] [unique-container-same-field] [unique-container-different-field] [not-globally-reachable] Field-sensitive All 4 predicates Unique-store

  • ne-to-one

Simply [Dolby, Chien]

  • ne-to-one

[Laud] Move fields to container Copy fields to container Remove contained Keep contained

  • bject
  • bject

– p. 16/30

slide-17
SLIDE 17

Field Classification [contains-unique] [unique-container-same-field] [unique-container-different-field] [not-globally-reachable] Field-sensitive All 4 predicates Unique-store

  • ne-to-one

Simply [Dolby, Chien]

  • ne-to-one

[Laud] Move fields to container Copy fields to container Remove contained Keep contained

  • bject
  • bject

– p. 17/30

slide-18
SLIDE 18

Field Classification [contains-unique] [unique-container-same-field] [unique-container-different-field] [not-globally-reachable] Field-sensitive All 4 predicates Unique-store

  • ne-to-one

Simply [Dolby, Chien]

  • ne-to-one

[Laud] Move fields to container Copy fields to container Remove contained Keep contained

  • bject
  • bject

– p. 18/30

slide-19
SLIDE 19

Field Classification [contains-unique] [unique-container-same-field] [unique-container-different-field] [not-globally-reachable] Field-sensitive All 4 predicates Unique-store

  • ne-to-one

Simply [Dolby, Chien]

  • ne-to-one

[Laud] Move fields to container Copy fields to container Remove contained Keep contained

  • bject
  • bject

– p. 19/30

slide-20
SLIDE 20

Experiments Instrument benchmarks using Soot to record

getfield, putfield, putstatic and aastore.

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

p.f = c;

. . .

p.f = d;

. . .

  • [contains-unique](f)

– p. 20/30

slide-21
SLIDE 21

Experiments Instrument benchmarks using Soot to record

getfield, putfield, putstatic and aastore.

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

p.f = c;

. . .

q.f = c;

. . .

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

– p. 21/30

slide-22
SLIDE 22

Benchmarks compress javasrc-p

(Java to HTML)

db kawa-c

(Scheme compiler)

jack rhino-a

(Javascript interp.)

javac sablecc-j

(Parser generator)

jess sablecc-w mpegaudio schroeder-m

(Audio editor)

mtrt schroeder-s raytrace soot-c

(Bytecode optimizer)

toba-s

(Java native compiler)

– p. 22/30

slide-23
SLIDE 23

Fraction of Field Reads Inlinable

20 40 60 80 100 compress db jack javac jess mpegaudio mtrt raytrace javasrc-p kawa-c rhino-a sablecc-j sablecc-w schroeder-m schroeder-s soot-c toba-s Percent Field-spec. one-to-one Unique-store Simply one-to-one

– p. 23/30

slide-24
SLIDE 24

How Many Inlinable Fields are Important? Fields accounting for 90% of inlinable field reads compress 6 javasrc-p 6 db 1 kawa-c 20 jack 7 rhino-a 3 javac 8 sablecc-j 12 jess 5 sablecc-w 8 mpegaudio 4 schroeder-m 4 mtrt 5 schroeder-s 4 raytrace 5 soot-c 20 toba-s 6

– p. 24/30

slide-25
SLIDE 25

Inlinable Field Reads per Second

200000 400000 600000 800000 1e+06 compress db jack javac jess mpegaudio mtrt raytrace javasrc-p kawa-c rhino-a sablecc-j sablecc-w schroeder-m schroeder-s soot-c toba-s Number of reads per second 8.3e+06 Field-spec. one-to-one Unique-store Simply one-to-one

– p. 25/30

slide-26
SLIDE 26

Speedup from Hand-Inlining compress Speedup 7.8% to 10.8% db Speedup up to 10.6% from one field javasrc-p No significant change

– p. 26/30

slide-27
SLIDE 27

Loop Invariant Hoisting Fields satisfying [contains-unique] predicate are loop invariant. Hoisting loop invariants should give similar benefit. In compress, benefit from loop invariant hoisting is about half the benefit of object inlining.

– p. 27/30

slide-28
SLIDE 28

Bytes of Allocations Saved

2 4 6 8 10 compress db jack javac jess mpegaudio mtrt raytrace javasrc-p kawa-c rhino-a sablecc-j sablecc-w schroeder-m schroeder-s soot-c toba-s Percent Field-spec. one-to-one Simply one-to-one

– p. 28/30

slide-29
SLIDE 29

Object Allocations Saved

5 10 15 20 25 compress db jack javac jess mpegaudio mtrt raytrace javasrc-p kawa-c rhino-a sablecc-j sablecc-w schroeder-m schroeder-s soot-c toba-s Percent Field-spec. one-to-one Simply one-to-one

– p. 29/30

slide-30
SLIDE 30

Conclusions Object inlining can produce speedups of up to 10%, but highly dependent on individual benchmark. Complex interactions with other

  • ptimizations; cost of “pointer chasing”

insignificant in comparison. Inlining field-specific one-to-one fields can yield savings of up to 7% of bytes, 21.6% of

  • bjects allocated.

Small number of fields are important could be hand-optimized.

– p. 30/30