Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Deep dive into runtime features provided by Go1.22
Search
sivchari
June 13, 2024
250
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Deep dive into runtime features provided by Go1.22
sivchari
June 13, 2024
More Decks by sivchari
See All by sivchari
go test を速くする
sivchari
4
1.5k
govalid ~ Type-safe validation tool ~
sivchari
0
210
Go1.25 リリースパーティ ~ nil pointer bug ~
sivchari
0
200
Google Developer Group - DevFest Tokyo 2025
sivchari
0
210
Who tests the Tests ?
sivchari
0
250
Go 1.26 リリースパーティ
sivchari
0
290
静的解析 x Kubernetes API Conventions = Kube API Linter ~ ベストプラクティスに準拠したカスタムリソースの作り方と運用 ~
sivchari
0
330
What's GOCACHEPROG ?
sivchari
1
650
gh_extensionsによる快適なOSS生活.pdf
sivchari
0
240
Featured
See All Featured
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
530
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
750
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
320
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
270
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
Transcript
Deep dive into runtime features provided by Go1.22 <03/18/23> Takuma
Shibuya CyberAgent Inc. sivchari
• Takuma Shibuya ◦ sivchari • CIU ◦ AKE •
Go Next Experts • Go Conference Host
runtimeパッケージの変更点 SECTION ONE
runtime/metrics • 4つのメトリクスが追加 (#63340) ◦ /sched/pauses/stopping/gc:seconds ◦ /sched/pauses/stopping/other:seconds ◦ /sched/pauses/total/gc:seconds
◦ /sched/pauses/total/other:seconds • /runtime/proc.go ◦ GCMark or GCTerm以外はOtherとしてMetricが加算される ◦ /gc/pauses:secondsはDeprecated ◦ /sync/mutex/wait/total:secondsにinternal lockも含まれる SECTION ONE
runtime/pprof • mutexのプロファイル記録が変更 ◦ 100個のgoroutineが10 millisecずつ遅延 ◦ 10 millisecでの記録ではなく 1secとして記録される
◦ より正確にボトルネックの度合いを表現 • Internal mutex lockはruntime._LostContendedRuntimeLock で報告される • Darwinプラットフォームの CPUプロファイルにメモリマップが入り、逆 アセンブルができるようになった SECTION TWO
runtime/trace • runtime/traceの抱えていたいくつかの課題が解決された • ほとんどのプラットフォームで os.clockを使うようになった • traceがパーティショニングされるようになったためストリーマブルな 処理が可能になった •
traceにsystem callの継続時間やスレッド周りの情報が入った SECTION THREE
runtime/trace • 実験的にこれらを利用した trace pacakgeであるexp/traceが公開 された ◦ 現時点では 1.22でしか動かない ◦
GOEXPERIMENT=noexectracer2で古い実装に戻せる • trace実行と終了のレイテンシが大幅に減少 • GCのMarkphaseの間に開始と終了ができるようになった • https://blog.felixge.de/reducing-gos-execution-tracer-ove rhead-with-frame-pointer-unwinding/ SECTION THREE
runtime/trace • G, M, Pの中でPに紐づけたバッファにイベントを書き込む ◦ HACKING.md ◦ GやMに比べて一般的に Pは少ないためバッファの数を最小にで
きる ▪ Preemption/IO Wait • 同期を考えると STWなどの際に Psを利用することが有用である SECTION THREE
traceを触ってみる • https://go.dev/blog/execution-traces-2024 ◦ Design Doc • Go1.21までのtraceの問題点 ◦ 高いオーバーヘッド
◦ 適切にスケールできず分析するにはでかすぎる ◦ 特定の悪い挙動を補足する時にいつトレースを開始すればいい かが不明瞭 ◦ 実行トレースの解析パッケージがなかったためプログラム上での 分析が困難 SECTION THREE
まとめ • runtime周りの複数の改善によってメトリクスまわりなどに改修が 入った • pprofのmutextプロファイルは個人的にとても嬉しい • Trace周りの変更は G,M,Pの取扱が絡むため深い理解には HACKING.mdが必要そう
• FlightRecorderによりコード内部で G,M,Pが扱えるようになった ◦ e.g. Middleware/GMPを扱えるのでそれを使ったツール ▪ goroutine scheduler simulatorつくれるかやってみる ◦ とはいえ使いどころはしっかりと考えよう SECTION THREE