Survey:
A Framework for Reducing the
Cost of Instrumented Code
hayami
※ Matthew Arnold and Barbara G. Ryder, PLDI’01
2015/10/1
1
研究の概要
Profilingの実行時オーバーヘッドを低減する
framework
低オーバーヘッド (~6%)
高精度 (93-98% overlap)
実現方法
Code duplication
Counter-based sampling
2015/10/1
2
発表の手順
背景
Framework
実験
まとめ
2015/10/1
3
背景
Adaptiveな最適化
ProfilingからのFeedback
メソッドの実行頻度 → Inlining,…
例 HotSpot, Jalapeño JVM
よく実行されるメソッドをJITコンパイル・最適化
2015/10/1
4
コード改造によるprofiling
(Profiling by Code Instrumentation)
利点
実装が簡単
foo() {
…
}
柔軟性が高い
foo() {
numInvokeFoo++;
…
}
Instrumented code
欠点
実行時のオーバーヘッドが大きい
Profilingによっては30%~1,000%以上
Samplingが有効
2015/10/1
5
研究の目的
profiling framework
汎用的、コード改造手順・OS等に依存しない
低コスト・高精度
Instrumened
Method
High overhead
2015/10/1
Instrumentation
Sampling
Framework
Modified
Instrumened
Method
Low overhead
6
Framework
2015/10/1
7
Frameworkの特徴
ハードウェア、OSに非依存
Sampling intervalを調整可
複数のInstrumentationの混在可
Deterministic
※ただし、コード量は増加 (約2倍)
2015/10/1
8
Frameworkの概要
コードを複製
Instrumentedなコード、Non-〃なコードの間をswitching
switchのタイミングをカウンタで制御
Checking
Code
2015/10/1
switching
Duplicated
Code
(non-instrumented)
(Instrumented)
Low overhead
High overhead
9
コード複製の手順
Checking code
メソッドのEntryとBackedgeにcheckを挿入
条件成立でDuplicated codeにとぶ
Duplicated code
(もと)backedgeでChecking codeに戻る
2015/10/1
10
コードの複製の例
original
modified
Entry check
A
A
B
B
C
D
E
2015/10/1
C
Backedge
check
A’
B’
D
E
Checking
C’
D’
E'
Duplicated11
Switchのタイミング
ハードウェア、OSのタイマーを利用
オーバーヘッドは小さい
でも…
精度に難あり (→ 実験: 精度の比較)
Non-deterministic
汎用frameworkでなくなる
2015/10/1
12
カウンタによるタイミング制御
“check” n回につき1回switch
if (globalCounter <= 0) {
globalCounter = n;
goto DuplicatedCode;
}
globalCounter--;
利点
単純、柔軟
ハード、OSには非依存
2015/10/1
13
実験
2015/10/1
14
実験環境・設定
Jalapeño JVMに実装
Optimizing Compilerに組込み
SPECjvm98+α
実行時間 1.1~4.8秒
333MHz powerPC 604e, 2GB RAM, AIX4.3
2015/10/1
15
Instrumentationの例
Call-edge instrumentation
Call-edge(caller, callee, call-siteの組)
メソッドの先頭でcall-edgeを調べる
Without framework: 88.3%のオーバーヘッド
Field-access instrumentation
全クラスの全フィールド毎にカウンタを用意
フィールドの読み書きのたびに+1
Without framework: 60.4%のオーバーヘッド
2015/10/1
16
実験
オーバーヘッド
Framework (checking codeのoverhead)
Total (checking code + duplicated code)
精度
Intervalと精度の関係
Timer-basedとCounter-basedの比較
2015/10/1
17
Framework Overhead
globalCounterの値は十分大きい
2015/10/1
Benchmarks
compress
jess
db
javac
mpegaudio
mtrt
jack
opt-compiiler
pBOB
Volano
平均
Framework Overhead (%)
8.7
3.3
2.1
2.7
9.9
3.4
8.4
6.2
3.8
1.4
4.9
18
Total Overhead
全ベンチマークの平均
Sample Interval
1
10
100
1,000
10,000
100,000
2015/10/1
Total Overhead (%)
182.2
29.3
10.3
6.3
5.1
5.0
19
Intervalと精度の関係
全ベンチマークの平均
Sample Interval Call-Edge(% overlap)
1
100
10
99
100
98
1,000
94
10,000
82
100,000
71
2015/10/1
Field-Access (% overlap)
100
100
99
97
94
83
20
Timer-basedと
Counter-basedの比較
Sample-Interval: 10m秒 or 30,000カウント
100
90
精度 (% overlap)
80
70
60
Timer-based (%)
Counter-based (%)
50
40
30
20
10
2015/10/1
jav
ac
ga
ud
io
m
trt
op
tj
co ack
m
pii
le
r
pB
O
Vo B
lan
o
平
均
pe
ss
je
db
m
co
m
pr
es
s
0
21
考察
オーバーヘッド (平均)
Framework overhead(4.9%) + 0.1~1.4%
コード改造に凝らなくてもよい
Timer-basedなsamplingより
高精度、細粒度
2015/10/1
22
まとめ
Instrumentationサンプリングのための
framework
低オーバーヘッド(~6%)
高精度(93-98% overlap)
ハードウェア、OS非依存
Code duplication
Counter-based sampling
2015/10/1
23
参考文献
Matthew Arnold and Barbara G. Ryder,
“A Framework for Reducing the Cost of
Instrumented Code”, PLDI’01
Matthew Arnold, Stephen Fink, David
Grove, Michael Hind and Peter F.
Sweeney, “Adaptive Optimization in the
Jalapeño JVM”, OOPSLA’00
2015/10/1
24
© Copyright 2026 ExpyDoc