Contenu connexe Similaire à JDK Mission Control: Where We Are, Where We Are Going [Groundbreakers APAC 2019 Tokyo] (20) JDK Mission Control: Where We Are, Where We Are Going [Groundbreakers APAC 2019 Tokyo] 1. The following is intended to outline our general product direction. It is intended for information purposes
only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code,
or functionality, and should not be relied upon in making purchasing decisions. The development,
release, timing, and pricing of any features or functionality described for Oracle’s products may change
and remains at the sole discretion of Oracle Corporation.
Statements in this presentation relating to Oracle’s future plans, expectations, beliefs, intentions and
prospects are “forward-looking statements” and are subject to material risks and uncertainties. A detailed
discussion of these factors and other risks that affect our business is contained in Oracle’s Securities and
Exchange Commission (SEC) filings, including our most recent reports on Form 10-K and Form 10-Q
under the heading “Risk Factors.” These filings are available on the SEC’s website or on Oracle’s website
at http://www.oracle.com/investor. All information in this presentation is current as of September 2019
and Oracle undertakes no duty to update any statement in light of new information or future events.
Safe Harbor
Copyright © 2019 Oracle and/or its affiliates.
2. JDK Mission Control:
Where We Are, Where We Are Going
Principal Member of Technical Staff
Java Platform Group
October 24, 2019
David Buck
Copyright © 2019 Oracle and/or its affiliates.
3. JVM Sustaining Engineer
OpenJDK 8 Update Project
Maintainer
JavaOne Rock Star
Co-author of Oracle WebLogic
Server 11g 構築・運用ガイド
@DavidBuckJP
https://blogs.oracle.com/buck/
Hello! David Buck (左)
4. • 背景
• 歴史
• ビルド
• デモ(脱線話含み)
• まとめ
Copyright © 2019 Oracle and/or its affiliates.
Agenda
6. 複数の技術
• (JRockit / Java / JDK) Mission Control
• Flight Recording
• Oracle JDK: JDK 7
• OpenJDK: JDK 11
• JEP 167: Event-Based JVM Tracing (JDK 7)
• JEP 328: Flight Recorder (JDK 11)
8. Mission Control
• Eclipse ベースの GUI ツール
• Flight Recording データの表示
• Flight Recording の自動分析
• リアルタイム監視・管理のための JMX コンソール
• 拡張機能を追加するための Plug-in フレームワーク
• Eclipse IDE に組み込で利用することも可能
9. Mission Control
• Eclipse ベースの GUI ツール
• Flight Recording データの表示
• Flight Recording の自動分析
• リアルタイム監視・管理のための JMX コンソール
• 拡張機能を追加するための Plug-in フレームワーク
• Eclipse IDE に組み込みで利用することも可能
12. JRockit
• Stockholm にあった Appeal Virtual
Systems によって開発された
• JITのみ JVM (インタプリタなし)
• Intel (x86 / AMD64 / IA64) のパフォー
マンスに注目
13. 「Value Add」(付加価値)
• 最初は “Virtual Machine for Java”として販売された
• Java のライセンスを取得するには「value add」が必要
• 「Sun より速いぞ!」とはあまり喜んでもらいなかったそうだ
• JRockit の管理・監視ツールが「value add」として認められた
15. By VARA - Beeld- en Geluidwiki, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=49198465
26. JVM 機能の統合
• HotSpot が JRockit の一番いい機能を導入
• 診断コマンド (JDK 7)
• コンパイル管理 (JDK 9)
• ネイティブメモリ追跡 (JDK 7)
• Flight Recorder (JDK 7)
• ビルドの仕組み(内部) (JDK 8)
• JRockit Mission Control -> Java Mission Control
28. JRockit Runtime Analyzer
• コンサルティングの経験に基づいた
• やり取りの回数を減らすために幅広くデータを収集
• JVM 内部の既存処理にてデータを所得するので追加負荷を抑える
• 圧縮された XMLとしてデータを格納する
31. JRockit Mission Control 4
• Oracle 買収後 (JRockit R28)
• JRockit Runtime Analyzer -> Flight Recorder
• XML データ -> バイナリデータ
• データ収集と格納のオーバーヘッドが減る
34. JDK 7 JMC 5
JDK 8 JMC 5.5
JDK 9 JMC 6
JDK 10 JMC 6
36. JDK Mission Control 7
• オープンソース
• JDK に同梱されず (JDK 11 以降)
• Flight Recorder の実装もオーペンソース化 (JDK 11 以降)
40. “...you're doing an awesome job in building a real community and a
*very* open source project.“
- Red Hat の貢献者より Marcus Hirt へ
jmc-dev alias, November 8, 2018
41. 互換性
• JDK のバージョンによって Flight Recording の形式が異なる
• HotSpot の既存の記録は 将来の JMC で開ける(後方互換)
• JDK 11 の記録は JMC 7 以降を利用する必要がある
• 現時点で HotSpot のすべての記録を開けるのは JMC 7 のみ
53. Safepoints
• Stop-the-World の実装
• 実行スレッドを既知状態で停止する
• Java コードを実行するすべてのスレッドを停止する
JNI コードを停止する必要はない
• プリエンプションが利用されない
• ポーリングが利用される
By YPLeroux at English Wikipedia, CC BY 3.0, https://commons.wikimedia.org/w/index.php?curid=17734859
54. Safepoints
• Stop-the-World の実装
• 実行スレッドを既知状態で停止する
• Java コードを実行するすべてのスレッドを停止する
JNI コードを停止する必要はない
• プリエンプションが利用されない
• ポーリングが利用される
By YPLeroux at English Wikipedia, CC BY 3.0, https://commons.wikimedia.org/w/index.php?curid=17734859
55. Safepoint ポーリング
• インタプリタはいつでも止められる
• バイトコードの jump table を切り替えることで停止する
• ポーリングのオーバーヘッドはない
• C1/C2 JIT に明示的なポーリング処理を入れる必要がある
• ポーリング用のページをアドレス空間に設置する
• このページのアドレスを読むことでポーリングする
• ページのアクセス権限を変更することで safepoint を実施する
56. Copyright © 2019 Oracle and/or its affiliates.
dadd goto return
バイトコード アドレス
dadd
goto
return
iinc
iinc
jmp_table
57. Copyright © 2019 Oracle and/or its affiliates.
dadd
dadd 実装
次のバイトコードを読む
分岐テーブルで次のアドレスの調べる
分岐 (jump)
58. Copyright © 2019 Oracle and/or its affiliates.
dadd
dadd 実装
次のバイトコードを読む
分岐テーブルで次のアドレスの調べる
分岐 (jump)
goto
goto 実装
次のバイトコードを読む
分岐テーブルで次のアドレスの調べる
分岐 (jump)
59. Copyright © 2019 Oracle and/or its affiliates.
iinc
inc 実装
次のバイトコードを読む
分岐テーブルで次のアドレスの調べる
分岐 (jump)
goto
goto 実装
次のバイトコードを読む
分岐テーブルで次のアドレスの調べる
分岐 (jump)
60. Copyright © 2019 Oracle and/or its affiliates.
dadd goto return
バイトコード アドレス
dadd
goto
return
iinc
iinc
jmp_table
61. Copyright © 2019 Oracle and/or its affiliates.
dadd goto return
バイトコード アドレス
dadd
goto
return
iinc
iinc
jmp_table
バイトコード アドレス
dadd
goto
return
iinc
safepoint
64. コラッツの問題の例
2 1
3 10 5 16 8 4 2 1
4 2 1
5 16 8 4 2 1
6 3 10 5 16 8 4 2 1
7 22 11 34 17 52 26 13 40 20 10 5 16 8...
65. コラッツの問題の例
2 1
3 10 5 16 8 4 2 1
4 2 1
5 16 8 4 2 1
6 3 10 5 16 8 4 2 1
7 22 11 34 17 52 26 13 40 20 10 5 16 8...
70. コラッツ問題の検証
public static void main(String[] args) {
long num;
for (int i=2; i < Integer.MAX_VALUE; i++) {
num = i;
for (int j=0; j < Integer.MAX_VALUE; j++) {
num = next(num);
if (num == 1) break;
}
if (num != 1) {
System.out.println(i + " did not end at 1.");
System.exit(-1);
} else if (i % 1000000 == 0) {
System.out.println("done with " + i);
}
}
}
72. コラッツ問題の検証
public static void main(String[] args) {
long num;
for (int i=2; i < Integer.MAX_VALUE; i++) {
num = i;
for (int j=0; j < Integer.MAX_VALUE; j++) {
num = next(num);
if (num == 1) break;
}
if (num != 1) {
System.out.println(i + " did not end at 1.");
System.exit(-1);
} else if (i % 1000000 == 0) {
System.out.println("done with " + i);
}
}
}
73. コラッツ問題の検証
public static void main(String[] args) {
long num;
for (int i=2; i < Integer.MAX_VALUE; i++) {
num = i;
for (int j=0; j < Integer.MAX_VALUE; j++) {
num = next(num);
if (num == 1) break;
}
if (num != 1) {
System.out.println(i + " did not end at 1.");
System.exit(-1);
} else if (i % 1000000 == 0) {
System.out.println("done with " + i);
}
}
}
76. 従来のプロファイラー
• JVMTI / Bytecode 操作だと、safepoint でしか停止することが出来
ない
• Safepoint のポールの間の処理はプロファイラーから隠られている
85. まとめ
• JMC のオーペンソース化は成功した
• 使っている JDK のバージョン問わずに、 JMC 7 以降は推奨
• Oracle からの JMC 7 のバイナリのリリースは
近いうちに出る見込みです
• 今は自分で簡単にビルドすることが可能
• Flight Recording の AsyncGetCallTrace ベースのプロファイラーは他の
ツールより細かくパフォーマンスの情報を取得出来る
87. 参考資料
Marcus Hirt の Blog
http://hirt.se/blog/
The Universal Permissive License (UPL)
https://oss.oracle.com/licenses/upl/
88. Session Survey
Help us make the content
even better. Please complete
the session survey in the
Mobile App.
Copyright © 2019 Oracle and/or its affiliates.
89. The preceding is intended to outline our general product direction. It is intended for information purposes
only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code,
or functionality, and should not be relied upon in making purchasing decisions. The development,
release, timing, and pricing of any features or functionality described for Oracle’s products may change
and remains at the sole discretion of Oracle Corporation.
Statements in this presentation relating to Oracle’s future plans, expectations, beliefs, intentions and
prospects are “forward-looking statements” and are subject to material risks and uncertainties. A detailed
discussion of these factors and other risks that affect our business is contained in Oracle’s Securities and
Exchange Commission (SEC) filings, including our most recent reports on Form 10-K and Form 10-Q
under the heading “Risk Factors.” These filings are available on the SEC’s website or on Oracle’s website
at http://www.oracle.com/investor. All information in this presentation is current as of September 2019
and Oracle undertakes no duty to update any statement in light of new information or future events.
Safe Harbor
Copyright © 2019 Oracle and/or its affiliates.