Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
$ go tool traceを使ってみよう/ Let's use go tool trace
Search
nametake
December 11, 2017
Technology
2
2.7k
$ go tool traceを使ってみよう/ Let's use go tool trace
golang.tokyo #11(
https://techplay.jp/event/641403
)での発表資料です。
nametake
December 11, 2017
Tweet
Share
More Decks by nametake
See All by nametake
実例マッピングで要件のレビューサイクルを回してる話 / Example Mapping Review Cycle
nametake
1
1.1k
アルプ T-QAオンボーディング資料(2022年9月版) / Alp T-QA onboarding 2022-09
nametake
0
1.5k
定式化と自動化に取り組みますという話 / Work on formulation and automation
nametake
0
910
QAエンジニアが実例マッピングを2ヶ月運用した話 / Example Mapping for 2 months
nametake
3
6.1k
1人目QAエンジニアよもやま話 / QA Test Talk Vol.1
nametake
4
670
アルプでのAgile Testing / Alp Agile Testing
nametake
1
2.3k
CFD-Editorというツールを作ってみた話 / Made CFD-Editor
nametake
1
320
スタートアップで1人目QAエンジニアになった話 / Startup first QA
nametake
3
1.4k
テスト技法の話 / Testing techniques
nametake
5
4.7k
Other Decks in Technology
See All in Technology
エンジニアの育成を支える爆速フィードバック文化
sansantech
PRO
3
1.1k
レビューを増やしつつ 高評価維持するテクニック
tsuzuki817
2
840
コンピュータビジョンの社会実装について考えていたらゲームを作っていた話
takmin
1
480
Reading Code Is Harder Than Writing It
trishagee
2
110
TAMとre:Capセキュリティ編 〜拡張脅威検出デモを添えて〜
fujiihda
2
360
オブザーバビリティの観点でみるAWS / AWS from observability perspective
ymotongpoo
9
1.6k
依存パッケージの更新はコツコツが勝つコツ! / phpcon_nagoya2025
blue_goheimochi
3
180
運用しているアプリケーションのDBのリプレイスをやってみた
miura55
1
830
Apache Iceberg Case Study in LY Corporation
lycorptech_jp
PRO
0
130
利用終了したドメイン名の最強終活〜観測環境を育てて、分析・供養している件〜 / The Ultimate End-of-Life Preparation for Discontinued Domain Names
nttcom
2
310
AIエージェント元年
shukob
0
120
室長と気ままに学ぶマイクロソフトのビジネスアプリケーションとビジネスプロセス
ryoheig0405
0
370
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Done Done
chrislema
182
16k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.5k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
YesSQL, Process and Tooling at Scale
rocio
172
14k
It's Worth the Effort
3n
184
28k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
Six Lessons from altMBA
skipperchong
27
3.6k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.8k
The Cost Of JavaScript in 2023
addyosmani
47
7.3k
GitHub's CSS Performance
jonrohan
1030
460k
Transcript
$ go tool trace ͬͯΈΑ͏ גࣜձࣾωΫετΧϨϯγʔ @nametake
ࣗݾհ
@nametake
Goྺ1ͪΐͬͱ
ύϑΥʔϚϯεܭଌ
runtime/pprof net/http/pprof
package main import ( "log" "net/http" _ "net/http/pprof" "runtime" )
func main() { runtime.SetBlockProfileRate(1) log.Println( http.ListenAndServe("0.0.0.0:6060", nil), ) }
localhost:6060/debug/pprof/
None
None
None
None
None
$ go tool trace
None
͍ํઆ໌
runtime/trace
package main import ( "os" "runtime/trace" ) func main() {
f, err := os.Create("trace.out") if err != nil { panic(err) } defer f.Close() err = trace.Start(f) if err != nil { panic(err) } defer trace.Stop() }
$ go tool trace trace.out
ϑΝΠϧॻ͖ࠐΈ
f, err := os.Create("test.txt") if err != nil { panic(err)
} defer f.Close() for i := 0; i < 100; i++ { fmt.Fprintf(f, "line number: %d\n", i) }
None
ॲཧ࣌ؒ
ॲཧ࣌ؒ
ϓϩάϥϜ͕֬อͨ͠ώʔϓྖҬ
goroutineͷͱ࣮ߦ࣌ؒ
OSͷThreadͷͱ࣮ߦ࣌ؒ
Proc(CPU)Ͱॲཧ͍ͯ͠Δ༰
ͳΜ͔৭ʑͳใ
Goݴޠ ׂΓͱؾܰʹ syscallΛݺͿ
None
syscallͷݺͼग़͠
ͱ͍ͯ͋͠
syscallΛݺΜͰΔ
f, err := os.Create("test.txt") if err != nil { panic(err)
} defer f.Close() for i := 0; i < 100; i++ { fmt.Fprintf(f, "line number: %d\n", i) }
f, err := os.Create("test.txt") if err != nil { panic(err)
} defer f.Close() for i := 0; i < 100; i++ { fmt.Fprintf(f, "line number: %d\n", i) }
bufio
f, err := os.Create("test.txt") if err != nil { panic(err)
} defer f.Close() w := bufio.NewWriter(f) defer w.Flush() for i := 0; i < 100; i++ { fmt.Fprintf(w, "line number: %d\n", i) }
None
None
None
None
None
GUIͰ֬ೝग़དྷΔʂ
GC
None
GC
None
GCຖʹ֬อ͍ͯ͠͠Δ
n := 400000 list := []int{} for i := 0;
i < n; i++ { list = append(list, i) }
n := 400000 list := []int{} for i := 0;
i < n; i++ { list = append(list, i) }
n := 400000 list := make([]int, n) for i :=
0; i < n; i++ { list[i] = i }
None
GC͕ൃੜ͍ͯ͠ͳ͍
࠷ॳʹΨοπϦྖҬ֬อ
6ms → 2ms
ฒྻԽ
https://making.pusher.com/go-tool-trace/ Connʹॻ͖ࠐΈ
https://making.pusher.com/go-tool-trace/ ͜ͷ෦Ͱॻ͖ࠐΜͰ͍Δ
https://making.pusher.com/go-tool-trace/
https://making.pusher.com/go-tool-trace/ ଞͷϓϩηεͬͯͳ͍
https://making.pusher.com/go-tool-trace/
https://making.pusher.com/go-tool-trace/
https://making.pusher.com/go-tool-trace/ CPUΛແବͳ͘ར༻
͍Ζ͍ΖΘ͔Δ
શ෦ͷ͕ Θ͔ΔΘ͚Ͱͳ͍
CPUͷ༻ pprofͱ͔Λ ݟͨ΄͏͕͍͍
ϓϩάϥϜͷ ྲྀΕΛΔ
ͱΓ͋͑ͣ ݟͯΈΔ͚ͩͰ ͍͍͔
go traceͷ͜ͱɺ ࣌ʑͰ͍͍͔Β……ɹ ࢥ͍ग़͍ͯͩ͘͠͞