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
Goのパフォーマンス計測 / go performance measurement
Search
convto
February 20, 2019
Technology
710
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Goのパフォーマンス計測 / go performance measurement
go 標準のツールチェインでプロファイル取るときのメモ
convto
February 20, 2019
More Decks by convto
See All by convto
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
8.2k
Go 1.27 の標準パッケージに uuid が入った!のでいろいろ喋る / go_127_std_go_uuid
convto
3
920
monorepo の Go テストをはやくした〜い!~最小の依存解決への道のり~ / faster-testing-of-monorepos
convto
3
700
詳解!defer panic recover のしくみ / Understanding defer, panic, and recover
convto
0
440
MCPと認可まわりの話 / mcp_and_authorization
convto
2
1.7k
バクラクの認証基盤の成長と現在地 / bakuraku-authn-platform
convto
4
2.4k
gob バイナリが Go バージョンによって 出力が変わることについて調べてみた / Investigating How gob Binary Output Changes Across Go Versions
convto
0
190
Go 関連の個人的おもしろCVE 5選 / my favorite go cve
convto
3
640
バイナリを眺めてわかる gob encoding の仕様と性質、適切な使い方 / understanding gob encoding
convto
6
3.6k
Other Decks in Technology
See All in Technology
バイブコーディング時代のWebアプリ開発入門~Cloud Runで学ぶセキュアなビルドとデプロイ
waiwai2111
1
140
ソフトウェアDNAとクラウドエージェントのススメ
cloudace
0
120
CLIライブラリ開発を支える技術
htnabe
0
150
AIで社員の自主発信に広報目線を組み込む
_mossann_t
0
140
AIを活用するために決めた "やらないこと" - 価値に注目する / Not betting on AI
soudai
PRO
3
590
手を動かして実感する、Kiro が変える開発体験
inariku
0
190
Making AI Agents Safe and Fast- Jev, Obsidian, and the Meta-Harness
x5gtrn
PRO
0
120
データ_AIの事業の勝敗をわけるもの
nek0128
1
480
C#コードの結合を可視化する Roslyn解析による設計改善と リファクタリング判断
dora56
0
480
GoのInterface内部構造から学ぶ!最高パフォーマンスを出すコード設計
yappli_developers
1
270
Azure Serverless 2026:Production-ready な AI エージェント基盤 / Azure Serverless 2026: Production-Ready AI Agent Platform
miyake
2
540
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
16
120k
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
Facilitating Awesome Meetings
lara
57
7.1k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
530
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
560
Faster Mobile Websites
deanohume
310
32k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
RailsConf 2023
tenderlove
30
1.6k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.9k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Transcript
Goのパフォーマンス計測 2019/02/20(水) Makuake LT Party #9
convto jisibari Twitter: @convto Github: convto 2
もくじ - どういう時に必要? - bench mark test - pprof (with
test) - pprof (埋め込み) - pprof (with http) - runtime - まとめ
もくじ - どういう時に必要? - bench mark test - pprof (with
test) - pprof (埋め込み) - pprof (with http) - runtime - まとめ
どういう時に必要? - ボトルネック調査 - コードレビュー - その他
どうせツールの導入が大変でしょ...?
標準のツールチェイン&パッケージでできます - testing - runtime/pprof - runtime
標準のツールチェイン&パッケージでできます - testing - runtime/pprof - runtime Thank you
除霊
どういう時に必要? - ボトルネック調査 - コードレビュー - その他
どういう時に必要? - ボトルネック調査 - コードレビュー - その他 気軽に試せるのでぜひ
もくじ - どういう時に必要? - bench mark test - pprof (with
test) - pprof (埋め込み) - pprof (with http) - runtime - まとめ
Bench mark test - testingパッケージでできる - `Benchmark` プレフィックスが対象 - `$
go test -bench .` で実行できる - オプションがいくつかある
例
実行
実行 実行回数 1回あたり実行時間
実行 実行回数 1回あたり実行時間 1回あたり使用メモリ 1回あたりメモリ割り 当て回数
もくじ - どういう時に必要? - bench mark test - pprof (with
test) - pprof (埋め込み) - pprof (with http) - runtime - まとめ
runtime/pprofパッケージ - runtimeパッケージのwrapperみたいなもの - 可視化ツールで想定されている形式で調査結果 を吐き出す - 可視化は `go tool
pprof` を利用する
“ Package pprof writes runtime profiling data in the format
expected by the pprof visualization tool. https://golang.org/pkg/runtime/pprof/
pprof (with test) - benchmark の結果をプロファイルとして出力する 機能 - `go test`
コマンドに組み込まれている - `go test -memprofile mem.out -bench .` のように実 行する
pprof (with test) - benchmark の結果をプロファイルとして出力する 機能 - `go test`
コマンドに組み込まれている - `go test -memprofile mem.out -bench .` のように実 行する テストコードをいじるだけでできます ビルドされるコードに影響はでません
実行
[demo] 吐かれたプロファイルを go tool で 分析してみる
もくじ - どういう時に必要? - bench mark test - pprof (with
test) - pprof (埋め込み) - pprof (with http) - runtime - まとめ
pprof (埋め込み) - スタンドアロンなプログラムで使う - バイナリに埋め込むので配布先でもプロファイル が吐ける
ドキュメントで紹介されている例
ドキュメントで紹介されている例 main関数にこれを埋めるとプロファイル吐け るようになる
もくじ - どういう時に必要? - bench mark test - pprof (with
test) - pprof (埋め込み) - pprof (with http) - runtime - まとめ
pprof (with http) - net/httpのサブパッケージ(net/http/pprof)を使う - HTTP経由でプロファイルを取得できる - testも書いてないし、バイナリに埋め込むのは面 倒、とかでサクッと試す時におすすめ
こう書く
こうやってプロファイルとる
対応してるエンドポイント - http://localhost:6060/debug/pprof/profile - http://localhost:6060/debug/pprof/heap - http://localhost:6060/debug/pprof/block - http://localhost:6060/debug/pprof/mutex -
より詳しくはこちら https://golang.org/pkg/net/http/pprof/
もくじ - どういう時に必要? - bench mark test - pprof (with
test) - pprof (埋め込み) - pprof (with http) - runtime - まとめ
runtimeパッケージでもパフォーマンス観測はできる - たとえば https://golang.org/pkg/runtime/#MemProfile を 使ったりする - が、ドキュメントでも「ほとんどの場合はpprof使っ た方がいいよ」とちょいちょい出てくる
runtimeパッケージのメリット - https://golang.org/pkg/runtime/#ReadMemStats を使うとstack 領域のメモリ使用量がわかる - pprofはstackは基本的に読めない、heapのみ - その他、比較的低レイヤーな処理を生で触れる
runtimeパッケージのメリット - https://golang.org/pkg/runtime/#ReadMemStats を使うとstack 領域のメモリ使用量がわかる - pprofはstackは基本的に読めない、heapのみ - その他、比較的低レイヤーな処理を生で触れる ランタイムレベルの操作をサポートするパッ
ケージなので、wrapperがあれば 理由がない限りそっちを使おう
こうやってプロファイルとる
もくじ - どういう時に必要? - bench mark test - pprof (with
test) - pprof (埋め込み) - pprof (with http) - runtime - まとめ
まとめ - Goは標準でいろいろ覗けるからよい - pprofは色々な方法で使える - runtimeでの計測は基本しなくていい
- プレゼンテーションテーマは SlidesCarnival の ヨークプレゼンテーションテンプレー ト を利用しています クレジット表記
ご静聴ありがとう ございました