MacBook Pro with an Apple M1 Pro chip. n Scala 3.3.1 n JDK 21 n https://github.com/takat0-h0rikosh1/scala-matsuri-2024 Note Information on the codes listed on this slide. スライドに登場するコードに関する事前情報です。
and manage threads within the JVM n Reduce overhead with creating and managing threads n High throughput. Virtual Threads Virtual Threads は JVM 上で作成・管理される軽量スレッドです。 Fiber と呼ばれていたりします。
Threads Virtual Threads Threading style Thread-per platform Thread-per-request style Creation & Context Switching High Cost Low Cost Scalability Millions of threads not practical A Millions of threads possible Thread Pool Management Required Do not pool Compute Large Data Fair Poor スレッドをプールせずに100万スレッド⼀気にスケールすることが可能です。
ex). pub/sub, large request count Use case Not well-suited for computationally expensive or large- data processing tasks. Ref: https://openjdk.org/jeps/444 I/Oブロックが発⽣しつつも⾼いスループットが要求されるシーンに最適です。 ⼀⽅で⼤規模なデータの計算処理にはあまり向きません。
tasks and subtasks n Control task lifetime n maintainable, reliable, and observable Structured Concurrency タスク間の関係・⽣存期間を管理する機能です。 メンテナンス性/可⽤性/観測性を向上します。
Scope ZIO の Scope を活⽤することでタスクの⽣存期間の ⾒通しが⽴てやすくなります。 Console Still running ... Still running ... Still running ... The innermost scope is about to be closed. Still running ... Still running ... Still running ... Still running ... Still running ... Still running ... The outer scope is about to be closed.
ZIO の Scope と同等の機能です。 Console Still running ... Still running ... Still running ... The innermost scope is about to be closed. Still running ... Still running ... Still running ... Still running ... Still running ... Still running ... The outer scope is about to be closed.