Java読書会「Java 11 and 12 - New Features」を読む会 第3回に参加
- chapter 8:ZGC
- Chapter9:Flight Recorder and Mission Control
- chapter 10:Miscellaneous Improvements in JDK 11
- nest-based access
- Improving AArch64 intrinsics
- Removing the Java EE and CORBA modules
- A key agreement with Curve25519 and Curve448
- Unicode 10
- ChaCha20 and Poly1305 cryptographic algorithms
- Launch single file source code programs
- TLS 1.3
- Deprecate the Nashorn JavaScript engine
- Deprecate the pack200 tools and API
- chapter 11:Switch Expressions
- chapter12 Miscellaneous Improvements in JDK 12
chapter 8:ZGC
- ZGC java11 から追加。フルスクラッチ実装の完全に新しいGC
- 今のところ64bit linuxのみ
- 10 milliseconds目標
- 早すぎないか?
- (10ms latencyを超える場合は)途中で中断するのでは?
- G1GC:8 millisecondsなのでそこまで早くない。
- 誤植:eve-decreasing:ever-decreasingの誤植(減り続ける)
- GCの進化は止まらない
- サーバーのメモリが増え続けてる
- load barriers?
- store barriersと共に一般的な用語
- color pointer?
- ZGC特有のアルゴリズム
references, soft references, phantom references, or finalizers (these are deprecated now). - refarences系はdeprecatedなのか? - deprecatedなのはfinalizersだけなのでは?
- conncurenntとパラレルは違う
- ZGCはG1GCと比較すると大きなオブジェクトの割り当てに向いている
- single-generation GC
- NUMA-aware
- マルチコアと相性が良い?
- 世代別ガベージコレクションが弱いのは寿命が長いオブジェクトが多い場合
- old領域のcompactionが最小になるようにチューニングする
GCはユーザーが指定する
ZGCの始め方
$ hg clone http://hg.openjdk.java.net/jdk/jdk $ cd zgc $ sh configure --with-jvm-features=zgc $ make images
class HelloZGC { public static void main(String[] args) { System.out.println("Say hello to new low pause GC - ZGC!"); } }
java -XX:+UnlockExperimentalVMOptions -XX:+UseZGC HelloZGC
- 自前でビルドしなくてもjava 11からデフォルトで入っている。(らしい)
Pause MarkStart Pause Mark End Pause Relocate Start
In this second phase, ZGC starts with reference processing and moves to week-root cleaning.
week-rootではなく、weak-rootではないか
remapは重い処理なので、Puse Relocate Startは 次のフェーズのPause Mark Startと並行して動く
p101
Colored pointers
- x32でのサポートはない
18 bits: Unused bits 1-bit: Finalizable 1-bit: Remapped 1-bit: Marked1 1-bit: Marked0 42 bits: Object Address
42bit:4TBが上限?少ないのでは。
The 42 bits can address up to 4 TB of address space.
- 必ずしも1バイト単位でアドレッシングするわけではない
- java13ではmax heapが4TBから16TBに変わった
https://jdk.java.net/13/release-notes
ZGC: Maximum Heap Size Increased to 16TB (JDK-8221786)
- Object Addressを42bitから44bitに変更したらしい。
ZPlatformAddressOffsetBits to 44, but we should take the opportunity to make this slightly more dynamic and set ZPlatformAddressOffsetBits at runtime. (上記java13 releace-notes)
Tuning option
- ヒープ数:-Xmx
- スレッド:ConcGCThreads
- -XX:+UseLargePages
- -XX:+UseNUMA
- ヒープ数:-Xmx
zgcは期待の星?
ZGCの情報は以下のwikiにまとまっている
https://wiki.openjdk.java.net/display/zgc/Main
MCは本書記載のURL(from https://jdk.java.net/jmc/.)からDLできない。
Chapter9:Flight Recorder and Mission Control
- 格JDKを配布しているサイトを探してDLすること。
https://mobile.twitter.com/boochnich/status/1149359338172977152
- JFR:プロファイラをバイナリで記録する
Java Flight Recorder (JFR) is a high-performance, low-overhead profiler that is built into the JVM.
JFR records the events from OS, HotSpot JVM, and JDK binary events as binary data. This essentially means that you need a parser, such as Mission Control (MC), to make sense of this binary data.
-
- そもそもこういうものにサポートは必要では
Epsilon GC
英文の意味がよくわからなかった。
Let's visit the preceding screenshot now—MC displays a consolidated report on how your application fares overall.
fare=活動?
JFRやJMCでリアルタイムで見えるのか?
- JMXならリアルタイムで見えるはず。
p118のコード
- 500スレッドがIOを取り合ってる。
Objectsがlock対象になっているのはなぜか?(p110)
chapter 10:Miscellaneous Improvements in JDK 11
nest-based access
- https://openjdk.java.net/jeps/181
Improving AArch64 intrinsics
Java.lang.mathの改善
- sin()
- cos()
- log()
In order to enhance application performance, intrinsics utilize an assembly code that is specific to CPU architecture. It does not execute generic Java code.
http://gruntthepeon.free.fr/ssemath/neon_mathfun.html
Armはsin,cos,logなどを直接計算できる専用命令があるので、それを直接使う。
Removing the Java EE and CORBA modules
https://openjdk.java.net/jeps/320
- CORBAやJAXBなどがJava SEから消える
- そもそもまともなところはJavaのCORBAを使わずにサードパーティのものを使っているらしい?
- CORBAはそもそもJavaに組み込むべきではなかったような。
- CORBAは代替技術が出てきてない?⇨まだ使ってるところは使い続ける必要がある。
- C++,Java,PythonなどでCORBAを使ってネットワーク越しで通信できる。
- 代替候補としてはgRPC,json + webAPI,Protocol buffersなど
- microservice + gRPC
A key agreement with Curve25519 and Curve448
セキュリティ強化?よくわからん Curve25519 and Curve448の仕様
Unicode 10
https://openjdk.java.net/jeps/327
ChaCha20 and Poly1305 cryptographic algorithms
https://openjdk.java.net/jeps/329
Launch single file source code programs
https://openjdk.java.net/jeps/330
- 誰得昨日
- shebangを使いたい。
- https://en.wikipedia.org/wiki/Shebang_(Unix)
- .javaファイルクリック時に実行できるように設定してしまうとセキュリティリスクでは。
TLS 1.3
TLS 1.3が使えるようになった。
https://openjdk.java.net/jeps/332
Deprecate the Nashorn JavaScript engine
https://openjdk.java.net/jeps/335
Deprecate the pack200 tools and API
https://openjdk.java.net/jeps/336
However, these are becoming irrelevant in today's modern storage and transmission improvements. JEP 336 deprecates the pack200 and unpack200 tools, and also the corresponding pack200 API.
とあるがストレージは増え続けているものの、圧縮技術は普通に需要があるし、研究もされている。
- pack200だと一部のツールで内容の確認などができない。
chapter 11:Switch Expressions
damage += switch(plastic) { case STRAW -> 10; case BAG -> 11; case SPOON, FORK, KNIFE -> 7; case PLATE -> 15; case BOTTLE -> 20; };
https://openjdk.java.net/jeps/325
class Planet { private static long damage; public void use(SingleUsePlastic plastic) { damage += switch(plastic) { case STRAW -> 10; case BAG -> 11; case SPOON, FORK, KNIFE -> 7; case PLATE -> { int radius = 20; // Local variable break (radius < 10 ? 15 : 20); // Using // break to return // a value } case BOTTLE -> 20; }; } }
- 疑問:case中のblockでreturnを実行すると何が起こるのか?
chapter12 Miscellaneous Improvements in JDK 12
Shenandoah—a low-pause-time GC
https://openjdk.java.net/jeps/189
- 非世代別GC
- phase
- Initial Marking(stop-the-world)
- Concurrent Marking
- Final Marking(stop-the-world)
- Concurrent Compaction
The microbenchmark suite
https://openjdk.java.net/jeps/230
- パフォーマンステストに使える。
- System.currentTimeMillisなどを使った計測より高精度
- 何十回も実行して統計的に優位な値を計測する?
- 自分で遊んだりして計測するときはこれを使えば良さそう。
The JVM constants API
334
https://openjdk.java.net/jeps/334
和訳があった
http://kagamihoge.hatenablog.com/entry/2018/11/20/230807
- JDK開発者の世界。普通のアプリエンジニアは多分使わない。
One AArch64 port, not two
AArch64 portが2つあったのを1つに減らしたらしい。
- portって何?
https://openjdk.java.net/jeps/340
Default CDS archives
- JVMの起動が早くなる
p144まで読んだ。次回は「Abortable mixed collections for G1」から