Effectiveness of an Automatic Insertion of Safe Memory Reuses into ML-like Programs Oukseh Lee and...

12
Effectiveness of an Automatic Effectiveness of an Automatic Insertion of Safe Memory Reuses Insertion of Safe Memory Reuses into ML-like Programs into ML-like Programs Oukseh Lee and Kwangkeun Yi {oukseh; kwang}@ropas.snu.a c.kr Seoul National University January 12, 2004

Transcript of Effectiveness of an Automatic Insertion of Safe Memory Reuses into ML-like Programs Oukseh Lee and...

Page 1: Effectiveness of an Automatic Insertion of Safe Memory Reuses into ML-like Programs Oukseh Lee and Kwangkeun Yi {oukseh; kwang}@ropas.snu.ac.kr Seoul National.

Effectiveness of an Automatic Effectiveness of an Automatic Insertion of Safe Memory Reuses Insertion of Safe Memory Reuses into ML-like Programsinto ML-like Programs

Oukseh Lee and Kwangkeun Yi

{oukseh; kwang}@ropas.snu.ac.krSeoul National UniversityJanuary 12, 2004

Page 2: Effectiveness of an Automatic Insertion of Safe Memory Reuses into ML-like Programs Oukseh Lee and Kwangkeun Yi {oukseh; kwang}@ropas.snu.ac.kr Seoul National.

QuestionQuestion

Our SAS 2003 paper* presented an algorithm to replace allocations by memory reuse (or

destructive update); and some promising yet preliminary experiment numbers.

When and how much is it cost-effective? Space & time-wise. Before launching it inside our nML compiler.

* Oukseh Lee, Hongseok Yang, and Kwangkeun Yi. Inserting Safe Memory Reuse Commands into ML-like Programs. In Proceedings of the Annual International Static Analysis Symposium, volume 2694 of Lecture Notes in Computer Science, pp. 171-188, San Diego, California, June 2003.

Page 3: Effectiveness of an Automatic Insertion of Safe Memory Reuses into ML-like Programs Oukseh Lee and Kwangkeun Yi {oukseh; kwang}@ropas.snu.ac.kr Seoul National.

Example: Example: insertinsert

fun insert i l = case l of [] => i::[] | h::t => if i<h then i::l else let z = insert i t in h::z

fun insert b i l = case l of [] => i::[] | h::t => if i<h then i::l else let z = insert b i t in free l when b; h::z

1 2 3 4

1 2 3 4result

insert 5 l l

5

1 2 3 4result 6

Page 4: Effectiveness of an Automatic Insertion of Safe Memory Reuses into ML-like Programs Oukseh Lee and Kwangkeun Yi {oukseh; kwang}@ropas.snu.ac.kr Seoul National.

Analysis & Transformation Analysis & Transformation CostCost

lines cost (s)

si eve 29 0.001

mer ge 40 0.001

qsor t 41 0.001

queens 44 0.003

msor t 73 0.003

mi r age 245 0.015

l i f e 366 0.017

k- eval 645 0.220

kb 808 0.095

nucl ei c 3019 0.488

1,500~29,000 lines/sec

slope=1.46

Page 5: Effectiveness of an Automatic Insertion of Safe Memory Reuses into ML-like Programs Oukseh Lee and Kwangkeun Yi {oukseh; kwang}@ropas.snu.ac.kr Seoul National.

Reuse RatioReuse Ratio

total allocation reuse ratio(kilo words) (kilo words)

B C C/B

si eve 30829 26423 85.7%

mer ge 5860 2930 50.0%

qsor t 35997 30148 83.7%

queens 34641 1807 5.2%

msor t 21506 19064 88.6%

mi r age 20381 16857 84.4%

l i f e 10036 875 8.7%

k- eval 52894 16684 31.5%

kb 24473 940 3.8%

nucl ei c 31092 5491 17.7%

3.8%~88.6%of allocations are

avoided.

Page 6: Effectiveness of an Automatic Insertion of Safe Memory Reuses into ML-like Programs Oukseh Lee and Kwangkeun Yi {oukseh; kwang}@ropas.snu.ac.kr Seoul National.

Memory Peak ReductionMemory Peak Reduction

reuse peak peak (reuse)ratio (words) (words)

D E (D-E)/E

si eve 85.7% 690 300 56.5%

mer ge 50.0% 1197 606 49.4%

qsor t 83.7% 1189 334 71.9%

queens 5.2% 255 255 0.0%

msor t 88.6% 714 321 55.0%

mi r age 84.4% 1398 1361 2.6%

l i f e 8.7% 2346 1746 25.6%

k- eval 31.5% 1044 944 9.6%

kb 3.8% 27125 26501 2.3%

nucl ei c 17.7% 103677 89352 13.8%

0.0%~71.9%peak reduction

much reuse =much peak reduction

Page 7: Effectiveness of an Automatic Insertion of Safe Memory Reuses into ML-like Programs Oukseh Lee and Kwangkeun Yi {oukseh; kwang}@ropas.snu.ac.kr Seoul National.

Difference in Live CellsDifference in Live Cells

sieve(85.7%)

qsort(83.7%)

merge(50.0%)

msort(88.6%)

Page 8: Effectiveness of an Automatic Insertion of Safe Memory Reuses into ML-like Programs Oukseh Lee and Kwangkeun Yi {oukseh; kwang}@ropas.snu.ac.kr Seoul National.

Difference in Live CellsDifference in Live Cells

k-eval (31.5%) nucleic(17.7%)

queens(5.2%)

kb (3.8%)

Page 9: Effectiveness of an Automatic Insertion of Safe Memory Reuses into ML-like Programs Oukseh Lee and Kwangkeun Yi {oukseh; kwang}@ropas.snu.ac.kr Seoul National.

Difference in Live CellsDifference in Live Cells

life(8.7%)

mirage (84.4%)

Page 10: Effectiveness of an Automatic Insertion of Safe Memory Reuses into ML-like Programs Oukseh Lee and Kwangkeun Yi {oukseh; kwang}@ropas.snu.ac.kr Seoul National.

GC-time & Runtime GC-time & Runtime ChangesChanges

reuse runtime GC-time GC-time (reuse) runtime (flags) runtime (reuse)ratio A B B/A C (B-C)/B D (A-D)/A E (A-E)/A

( i n Sun Ul t r aSpar c, Sol ar i s)si eve 85.7% 7.15 2.82 39.4% 1.22 56.5% 7.44 -4.1% 7.11 0.6%

mer ge 50.0% 1.69 1.37 81.3% 0.78 43.4% 1.75 -3.6% 1.42 16.0%

qsor t 83.7% 4.97 3.21 64.5% 0.39 88.0% 5.08 -2.2% 4.10 17.5%

queens 5.2% 2.82 0.95 33.7% 0.95 -0.4% 2.99 -6.0% 3.01 -6.7%

msor t 88.6% 2.96 1.50 50.7% 0.35 76.9% 3.10 -4.7% 2.86 3.4%

mi r age 84.4% 1.85 0.07 3.9% 0.02 78.1% 2.00 -8.1% 2.25 -21.6%

l i f e 8.7% 5.19 0.06 1.1% 0.06 0.0% 5.21 -0.4% 4.86 6.4%

k- eval 31.5% 3.78 0.04 1.2% 0.04 11.4% 3.69 2.4% 3.97 -5.0%

kb 3.8% 2.85 0.73 25.5% 0.73 0.0% 2.96 -3.9% 2.99 -4.9%

nucl ei c 17.7% 2.70 1.16 42.9% 0.80 31.2% 2.71 -0.4% 2.70 0.0%

( i n I nt el Pent i um, Li nux)si eve 85.7% 0.78 0.39 49.7% 0.16 59.0% 0.81 -3.8% 0.89 -14.1%

mer ge 50.0% 0.24 0.17 71.7% 0.11 38.4% 0.26 -8.3% 0.23 4.2%

qsor t 83.7% 0.67 0.47 69.9% 0.05 88.5% 0.70 -4.5% 0.50 25.4%

queens 5.2% 0.33 0.13 38.2% 0.13 -1.6% 0.34 -3.0% 0.35 -6.1%

msor t 88.6% 0.39 0.21 54.4% 0.05 77.4% 0.40 -2.6% 0.35 10.3%

mi r age 84.4% 0.21 0.01 5.2% 0.00 81.8% 0.22 -4.8% 0.30 -42.9%

l i f e 8.7% 0.49 0.01 1.6% 0.01 0.0% 0.51 -4.1% 0.54 -10.2%

k- eval 31.5% 0.41 0.01 1.7% 0.01 14.3% 0.42 -2.4% 0.48 -17.1%

kb 3.8% 0.40 0.12 30.5% 0.12 3.3% 0.42 -5.0% 0.43 -7.5%

nucl ei c 17.7% 0.45 0.19 41.6% 0.14 27.8% 0.45 0.0% 0.45 0.0%

-1.6%~88.5%GC-time reduction

-42.9%~25.4%runtime reduction

Low reuse ratio: flags overhead

High reuse ratio &Small GC-time

portion: expansive reuse

in the Objective Caml system

5.2%

5.2%

3.8%

3.8%

-6.0% -6.7%

-3.9% -4.9%

-3.0% -6.1%

-5.0% -7.5%

High reuse ratio & Big GC-time portion: runtime reduction

50.0%83.7%

50.0%83.7%

88.6%

88.6%

81.3%64.5%

71.7%69.9%

16.0%17.5%

4.2%25.4%

50.7%

54.4%

3.4%

10.3%

84.4%

84.4%

31.5%

31.5%

5.2%

1.7%

3.9%

1.2%

-42.9%

-17.1%

-21.6%

-5.3%

Page 11: Effectiveness of an Automatic Insertion of Safe Memory Reuses into ML-like Programs Oukseh Lee and Kwangkeun Yi {oukseh; kwang}@ropas.snu.ac.kr Seoul National.

GC-time & Runtime GC-time & Runtime ChangesChanges

much reuse =

much GC-time reduction

much reuse & big GC-time portion

= much runtime reduction

Page 12: Effectiveness of an Automatic Insertion of Safe Memory Reuses into ML-like Programs Oukseh Lee and Kwangkeun Yi {oukseh; kwang}@ropas.snu.ac.kr Seoul National.

AnswerAnswer

programtransformation

resultprogram

performance

not muchsharing

+big GC-time

portionruntime speedup

high reuse ratio

memory peakreduction