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
890
QAエンジニアが実例マッピングを2ヶ月運用した話 / Example Mapping for 2 months
nametake
3
5.8k
1人目QAエンジニアよもやま話 / QA Test Talk Vol.1
nametake
4
650
アルプでのAgile Testing / Alp Agile Testing
nametake
1
2.2k
CFD-Editorというツールを作ってみた話 / Made CFD-Editor
nametake
1
310
スタートアップで1人目QAエンジニアになった話 / Startup first QA
nametake
3
1.3k
テスト技法の話 / Testing techniques
nametake
5
4.6k
Other Decks in Technology
See All in Technology
Amazon Kendra GenAI Index 登場でどう変わる? 評価から学ぶ最適なRAG構成
naoki_0531
0
100
Microsoft Azure全冠になってみた ~アレを使い倒した者が試験を制す!?~/Obtained all Microsoft Azure certifications Those who use "that" to the full will win the exam! ?
yuj1osm
1
110
C++26 エラー性動作
faithandbrave
2
660
NW-JAWS #14 re:Invent 2024(予選落ち含)で 発表された推しアップデートについて
nagisa53
0
250
MLOps の現場から
asei
6
630
podman_update_2024-12
orimanabu
1
260
日本版とグローバル版のモバイルアプリ統合の開発の裏側と今後の展望
miichan
1
120
統計データで2024年の クラウド・インフラ動向を眺める
ysknsid25
2
830
20241214_WACATE2024冬_テスト設計技法をチョット俯瞰してみよう
kzsuzuki
3
440
私なりのAIのご紹介 [2024年版]
qt_luigi
1
120
KubeCon NA 2024 Recap: How to Move from Ingress to Gateway API with Minimal Hassle
ysakotch
0
200
CustomCopを使ってMongoidのコーディングルールを整えてみた
jinoketani
0
220
Featured
See All Featured
Site-Speed That Sticks
csswizardry
2
190
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Reflections from 52 weeks, 52 projects
jeffersonlam
347
20k
Designing for Performance
lara
604
68k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Embracing the Ebb and Flow
colly
84
4.5k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
Making the Leap to Tech Lead
cromwellryan
133
9k
How to train your dragon (web standard)
notwaldorf
88
5.7k
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ͷ͜ͱɺ ࣌ʑͰ͍͍͔Β……ɹ ࢥ͍ग़͍ͯͩ͘͠͞