CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

27
CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA

Transcript of CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

Page 1: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

CACHETORDetecting Cacheable Data to

Remove Bloat

Khanh NguyenGuoqing Xu

UC IrvineUSA

Page 2: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

Introduction

• Bloat: Excessive work to accomplish simple tasks

• Modern software suffers from bloat [Xu et.al., FoSER 2010]

• It is difficult for compilers to remove the penalty

• One pattern: repeated computations that have the

same inputs and produce the same outputs

• 4 out of 18 best practices (IBM’s)* are to reuse data

Khanh Nguyen - UC Irvine* www.ibm.com/software/webservers/appserv/ws_bestpractices.pdf

Page 3: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

Example

float[] fValues = {0.0, 1.0, 2.3, 1.0, 1.0, 3.4, 1.0, 1.0, . . . , 1.0};

int[] iValues = new int[fValues.length] ;

for (int i = 0; i < fValues.length; i++){iValues[i] = Float.floatToIntBits(fValues[i]);

}{adapted from sunflow, an open-source image rendering system}

Khanh Nguyen - UC Irvine

if (fValues[i] == 1.0)iValues[i] = cached_result;

else iValues[i] = Float.floatToIntBits(fValues[i]);

int cached_result = Float.floatToIntBits(1.0);

float[] fValues = {?, ?, ?, ?, . . . , ?};

Page 4: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

The Big Picture

Khanh Nguyen - UC Irvine

Dynamic Dependence Analysis

Dependence Profile/Graph

I-Cachetor

D-Cachetor

M-Cachetor

Inst.: a = b+c;

Obj.: a = new A();

Call: a = f();

Page 5: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

Cachetor

• Introduction

• Scalable algorithms for the dependence

analysis

• 3 detectors

• Evaluations Khanh Nguyen - UC Irvine

Page 6: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

In Theory

Khanh Nguyen - UC Irvine

Full Value Profiling

Full Dynamic Slicing

Cachetor

In Practice

Abstract Value Profiling

Abstract Dynamic Slicing

Page 7: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

Overview

Khanh Nguyen - UC Irvine

• Combine value profiling and dynamic slicing in a mutually-beneficial and scalable manner• Distinct values are used to abstract instruction

instances• Result: an abstract dependence graph

• Nodes: abstract representations of runtime instances

• Edges: dependence relationships between nodes

Page 8: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

Equivalence Class

Khanh Nguyen - UC Irvine

e1

en

Inst. instances

f1

Instruction i

Page 9: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

Equivalence Class1

1

1

22

2

3

3

3

3

44

55

66

6

6

6

UnboundedInst. instances

Values created

f1(inst. instance) = value created

Page 10: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

Inst. instances

Values created

f1

f2

-Top-N ?- Hashing ?

UNBOUNDED

BOUNDEDSIZE N

Page 11: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

0

33

3

66

1

1

1

1

1 4

4 77

2

22

25

5

88

8

Inst. instances

Values created

f1

f2

- Hashing

value % N

SIZE N

Page 12: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

Another Abstraction Level

• Context sensitive:

• To distinguish entities based on the calling

context

• To improve the tool’s precision

• Please refer to our paper for details

Khanh Nguyen - UC Irvine

Page 13: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

Cacheability

• Quantitative measurement indicating how likely a program

entity will keep producing/containing identical values

• Compute cacheability for 3 kinds of program entities:

• Instruction a = b+c;

• Data structure a = new A();

• Method call a = f();

• Rank and report top entities

Khanh Nguyen - UC Irvine

Page 14: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

Cachetor

• Introduction

• Scalable algorithms for the dependence

analysis

• 3 detectors

• Evaluations 

Khanh Nguyen - UC Irvine

Page 15: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

I-Cachetor• Detect instructions that create identical values

• Compute cacheability for each static instruction (Inst.CM)

• Cacheability:

0 31 2

4/8 = 0.5

1 4 2 1

Page 16: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

D-Cachetor: Overview

• 2 steps:

• Step 1: detect cacheable individual objects

• Step 2: detect cacheable data structure

• Compute cacheability for each allocation site node

Page 17: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

D-Cachetor: Step 1• Compute cacheability for each object (Obj.CM),

not considering reference relationships

• Focus: instructions that write primitive-typed fields

a = new A()1

a.f = b<2,3> a.g = c<3,3> a.… = …

1 2… t

a.h = d<5,7>

Page 18: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

D-Cachetor: Step 2• Group objects using the

reference relationships

• Compute DataStructureCM

• Focus: instructions that write

reference-typed fields

• Add only objects whose Obj.CM

is within a range

ds = new DS()2

a = new A()4 b = new B()6

c = new C()2 d = new D()7

Page 19: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

M-Cachetor

• Detect method calls that have the same inputs and

produce the same outputs

• Compute CallSiteCM

• For each call site c: a = f( ), CallSiteCM is:

• If a is primitive: CallSiteCM = Inst.CMc

• If a is reference: CallSiteCM = the average of

DataStructureCM of all data structures rooted at a

Page 20: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

Implementation

• Jikes RVM 3.1.1

• Optimizing-compiler-only mode

• Context-sensitive

• Evaluated on 14 benchmarks from DaCapo & Java

Grande 

Khanh Nguyen - UC Irvine

Page 21: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

Overheads

Khanh Nguyen - UC Irvine

antlr

bloa

t fo

p

hsql

db

luin

dex

luse

arch

pm

d

xala

n

avro

ra

sunf

low

eule

r

mol

dyn

mon

teca

rlo

raytr

acer

Geo.M

ean

0

100

200

300

400

500

600

0

1

2

3

4

5

6

7

8

9

10Geo. Mean = 201.96X (Time) - 1.98X(Space)

Time Space

X X

Page 22: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

Case Studies

Khanh Nguyen - UC Irvine

Program Time Reduction

Space Reduction

GC runs Reduction

GC time Reduction

montecarlo 12.1% 98.7% 70.0% 89.2%

raytracer 19.1% 1.2% 33.3% 30.2%

euler 20.5% 0.4% 40.0% 44.8%

bloat 13.1% 12.6% -7.3% -4.0%

xalan 5.2% 0.1% -0.7% -1.1%

Page 23: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

False Positives

Khanh Nguyen - UC Irvine

Program D-Cachetor M-Cachetor

montecarlo 2 6

raytracer 3 4

euler 1 7

bloat 1 4

xalan 4 5

Numbers of false positives identified among top 20 items in the reports of D-Cachetor and M-Cachetor.

Page 24: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

False Positives Sources

• Handling of floating point values

• Context-sensitive reporting

• Missing the actual values

• Hashing-induced false positives

Khanh Nguyen - UC Irvine

Page 25: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

Conclusions

• Cachetor - novel tool, supports detection of cacheable data to improve performance• Scalable combination of value profiling and

dynamic slicing• 3 detectors that can detect cacheable:

o Instructionso Data structureso Method calls

• Large optimization opportunities can be found from Cachetor’s reports

Khanh Nguyen - UC Irvine

Page 26: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

THANK YOU!Questions - Comments?

Khanh Nguyen - UC Irvine

Page 27: CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.

What happened in montecarlo?

public void runSerial() { results = new Vector(nRunsMC); // Now do the computation. PriceStock ps; for( int iRun=0; iRun < nRunsMC; iRun++ ) { ps = new PriceStock();ps.setInitAllTasks(initAllTasks);ps.setTask(tasks.elementAt(iRun));ps.run();results.addElement(ps.getResult()); }

{Calculate the result on the fly}

private void processSerial() { processResults();}

ps.setTask(iRun, (long)iRun*11);

private void initTasks(int nRunsMC) { tasks = new Vector(nRunsMC); for( int i=0; i < nRunsMC; i++ ) {

String header= "MC run “ + String.valueOf(i); ToTask task = new ToTask(header, (long)i*11); tasks.addElement((Object) task); } } Khanh Nguyen - UC Irvine