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
Compare Benchmarks and Compiler Optimization I...
Search
po3rin
May 27, 2019
Programming
4
840
Compare Benchmarks and Compiler Optimization In Go
Go(Un) Conference #6
po3rin
May 27, 2019
Tweet
Share
More Decks by po3rin
See All by po3rin
LLMOpsのパフォーマンスを支える技術と現場で実践した改善
po3rin
8
980
LLMは麻雀を知らなすぎるから俺が教育してやる
po3rin
3
2.3k
M3におけるCI/CDパイプラインを新鮮に保つ仕組み
po3rin
0
370
Go Templateを使った フロントエンド開発を採用した 経緯と所感
po3rin
1
350
検索基盤移行時の思考
po3rin
0
4.3k
Go1.19で採用された Pattern-defeating Quicksort の紹介
po3rin
7
6.1k
Elasticsearchを負荷から守るesguard
po3rin
0
310
Sudachi×Elasticsearchへの移行と医療検索システム精度改善
po3rin
1
950
eskeeperを使ったファイル定義によるindex管理
po3rin
2
520
Other Decks in Programming
See All in Programming
オープンセミナー2025@広島LT技術ブログを続けるには
satoshi256kbyte
0
130
マイコンでもRustのtestがしたい その2/KernelVM Tokyo 18
tnishinaga
2
2.3k
あのころの iPod を どうにか再生させたい
orumin
2
2.5k
Understanding Ruby Grammar Through Conflicts
yui_knk
1
130
Terraform やるなら公式スタイルガイドを読もう 〜重要項目 10選〜
hiyanger
13
3.2k
Claude Codeで挑むOSSコントリビュート
eycjur
0
180
実践!App Intents対応
yuukiw00w
1
350
The state patternの実践 個人開発で培ったpractice集
miyanokomiya
0
150
UbieのAIパートナーを支えるコンテキストエンジニアリング実践
syucream
2
730
コーディングは技術者(エンジニア)の嗜みでして / Learning the System Development Mindset from Rock Lady
mackey0225
2
580
AHC051解法紹介
eijirou
0
620
AI OCR API on Lambdaを Datadogで可視化してみた
nealle
0
180
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
302
21k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
StorybookのUI Testing Handbookを読んだ
zakiyama
30
6k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3k
How STYLIGHT went responsive
nonsquared
100
5.7k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
61k
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.5k
A Tale of Four Properties
chriscoyier
160
23k
Done Done
chrislema
185
16k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.6k
Building an army of robots
kneath
306
46k
Transcript
Compare Benchmarks and Compiler Optimization In Go Go Un Conference
May 27, 2019 @ po3rin
@po3rin Software Enginner @ Shiroyagi Corporation QBHF Golang / Python
/ Rust / Docker / AWS / Elasticsearch
QBHF Introduction \
QBHF 044ʹίϛοτΛࢼΈΔࡍʹɺʮͳͥ ͜ͷ࣮͕ྑ͍͔ʯΛূ໌͢Δҝʹ (Pʹ͓͚ΔϕϯνϚʔΫʹ͍ͭͯௐ ͨͷͰͦΕΛൃද͠·͢ɻ Benchmark of Go Ὂ
QBHF ɾϕϯνϚʔΫΛʮূ໌ʯʹ͑ΔΑ͏ʹͳΔ ɾϕϯνϚʔΫٻ͔ΒίϯύΠϥ࠷దԽΛআ͘ Ὂ the porpose of this talk
QBHF Review how to take a benchmark \
QBHF Review how to take a benchmark Ὂ ֤ϕϯνϚʔΫؔC/ճ෮ ͞Ε·͢ɻσϑΥϧτͰC/
͔Β࢝·Γ·͕͢ɺϕϯνϚʔ Ϋػೳ͕ඵҎʹྃͨ͠߹ C/͕૿Ճͯ͠ϕϯνϚʔΫ͕࠶ ࣮ߦ͞Ε·͢ɻ
QBHF Review how to take a benchmark Ὂ ݁ՌΛݟΔͱͱ͍͏TV⒏Y͕͍͍ͭͯ·͢ɻ͜Ε͜ͷςετΛ࣮ߦ͢ΔͨΊ ʹ༻͞Εͨ(0."9130$4ͷͰ͢ɻ͜ͷσϑΥϧτͰىಈ࣌ʹ(Pϓϩ
ηεʹݟ͑Δ$16ͷʹͳΓ·͢ɻ
QBHF -cpu Ὂ (0."9130$4DQVϑϥάͰมߋͰ͖·͢ɻνʔϜؒͰϕϯνϚʔΫΛ͍ճ ࣌͢$16ͷ͕ϕϯνϚʔΫʹӨڹΛ༩͑ͳ͍Α͏ʹҙ͕ඞཁͰ͢ɻ
QBHF -benchtime Ὂ ෮ճΛ૿͢ҝʹ CFODIUJNFϑϥάΛ༻ ͯ͠ϕϯνϚʔΫ࣌ؒΛ ૿͢͜ͱ͕Ͱ͖·͢ɻ (P͔ΒCFODIUJNF ϑϥά෮ճΛࢦఆ Ͱ͖·͢ɻ
QBHF Benchmark cost avoidance Ὂ C3FTFU5JNFS ͰηοτΞοϓͰ ൃੜ͢ΔίετΛճආͰ͖·͢ɻ ϧʔϓͷ෮͝ͱʹίετ͕ߴ͍ ηοτΞοϓ͕͋Δ߹ɺ
C4UPQ5JNFS ͓Αͼ C4UBSU5JNFS Λ༻͠·͢ɻ
QBHF Check allocations Ὂ ΞϩέʔγϣϯͷͱαΠζɺϕϯνϚʔΫͱڧ͘૬͍ؔͯ͠·͢ɻΞϩέʔ γϣϯͷΛϕϯνϚʔΫͰ֬ೝ͢Δ࣌CFODINFNΛ͍·͢ɻ
QBHF Benchmark stability \
QBHF Benchmark stability Ὂ ඦສ·ͨेԯճ΄Ͳ෮࣮ߦ͞ ΕΔϕϯνϚʔΫ͕OTdNTͷൣғ ͷͳΔ߹ɺϕϯνϚʔΫε έʔϦϯάɺϝϞϦہॴੑͳͲ༷ʑͳ ཁҼʹΑΓෆ҆ఆʹͳ͍ͬͯ·͢ɻ
QBHF Benchmark stability Ὂ ͜ͷΑ͏ͳ߹DPVOUϑ ϥάΛ༻ͯ͠ɺϕϯν ϚʔΫΛෳճ࣮ߦ͢Δ͜ ͱͰϕϯνϚʔΫͷࢄ ؚΊͯ֬ೝ͢Δͷ͕ಘࡦͰ ͢ɻ
QBHF Benchmark stability Ὂ ҰํͰϕϯνϚʔΫͷ҆ఆΛݟΔͷʹศརͳπʔϧ͕͋Γ· ͢ɻ3VTT$PYʹΑΔCFODITUBUͱ͍͏πʔϧΛհ͠·͢ɻ
QBHF Benchmark stability Ὂ CFODITUBUҰ࿈ͷϕϯνϚʔΫ ςετΛ࣮ߦͯ͠ɺͦΕΒ͕ͲΕ ΄Ͳ҆ఆ͍ͯ͠Δ͔Λڭ͑ͯ͘Ε ·͢ɻ
QBHF Comparing benchmarks \
QBHF Comparing benchmarks Ὂ ϕϯνϚʔΫؒͷύϑΥʔϚϯεͷࠩΛஅ͢Δͷ໘Ͱ͕͢ɺ CFODITUBU͜ͷղܾ͠·͢ɻ
QBHF ૣ'JC Λվྑ͍ͨ͠ͷͰ͕͢ɺίʔυΛվྑͨ͠ޙͰɺ ͏ҰվྑલͷϕϯνϚʔΫΛऔΓ͍͕ͨ࣌ग़͖ͯͨΒ Ͳ͏͠·͠ΐ͏͔ɻ࣮HPUFTUʹલճͷϕϯνϚʔΫ݁ ՌΛੜͨ͠όΠφϦΛอଘ͓ͯ͘͜͠ͱ͕Ͱ͖ΔػೳΛ ఏڙ͢ΔDϑϥοά͕ଘࡏ͠·͢ɻվྑલͷόΠφϦ໊ UFTU͔ΒHPMEFOʹมߋ͢Δͷ͕௨ྫͷΑ͏Ͱ͢ɻ -c Ὂ
QBHF ϕϯνϚʔΫΛൺֱ͢Δҝ ʹ࠶ؼݺͼग़͠Λ̍ͭݮΒ ͠·͢ɻ Reduce recursive calls Ὂ
QBHF 'JC Ͱ'JC ͱൺͯͷվྑ͕֬ೝͰ͖·͢ɻιʔείʔυͷมߋ ޙʹͲͷ͘Β͍ͷվળ͕͋ͬͨͷ͔Λূ໌͢Δͷʹ༗༻Ͱ͢ɻࢄ͕େ͖͍ϕϯ νϚʔΫΛൺֱ͢Δͱ͖ҙɻ Comparing benchmarks
Ὂ
QBHF Oɺ༗ޮͩͱݟͳ͞ΕͨσʔλͷݸΛද͠·͢ɻσʔλͷغ٫͕ˋΛ͑ Δͱൺֱ͢Δαϯϓϧ͕গͳ͗͢ΔՄೳੑ͕͋Γ·͢ɻ Q͕Λ͑Δ͜ͱϕϯνϚʔΫ͕౷ܭతʹ༗ҙͰͳ͍͜ͱΛҙຯ͠·͢ɻ Qʹ͍ͭͯԼه͕ৄ͍͠Ͱ͢ɻ ౷ܭֶతݕఆͷ1ɺ౷ܭֶతʹ༗ҙɺ༗ҙࠩɺ༗ҙਫ४ͱԿ͔ʁ IUUQUPVLFJMJOLCBTJDTUBUJTUJDTQWBMVF@BOE@TJHOJpDBODF Comparing benchmarks Ὂ
QBHF Watch out for compiler optimisations \
QBHF ਐͰදͨ͠ͱཱ͖͍ͬͯΔ ϏοτͷΛฦ͠·͢ɻ͜ͷؔ ͷϕϯνϚʔΫΛͱΓ·͠ΐ ͏ɻ compiler optimisations Ὂ
QBHF ͜ͷ݁Ռͷඵ֓ͶΫϩοΫपͰ͢ɻΑͬͯ͜ͷ͔ͳΓ͓͔͍͠Ͱ͢ɻ $16ΫϩοΫ৴߸ʹ߹Θͤͯಈ࡞͠·͢ QPQDOUϦʔϑؔ ଞͷؔݺͼग़͠Λ͠ͳ͍ ʹͳ͍ͬͯ·͢ɻɻίϯύΠϥ͜ ͷؔΛΠϯϥΠϯల։Ͱ͖·͢ɻͦͯ͠QPQDOUɺͲͷάϩʔόϧมͷঢ়ଶʹ Өڹ͠·ͤΜɻ͕ͨͬͯ͠ɺݺͼग़ࣗ͠ମ͕ഉআ͞Ε͍ͯ·͢ɻ compiler
optimisations Ὂ
QBHF ϕϯνϚʔΫΛػೳͤ͞ΔͨΊʹΠϯ ϥΠϯԽΛແޮʹ͢Δ͜ͱଞͷϕϯ νϚʔΫʹӨڹ͕͋ΔͷͰ͓͢͢Ί ͠·ͤΜɻ্̎ͭίϯύΠϥ͕ϧʔ ϓຊମΛ࠷దԽͰ͖ͳ͍Α͏ʹ͢Δͨ Ίͷਪํ๏Ͱ͢ɻ compiler optimisations Ὂ
QBHF JOMJOJOHͳͲͷίϯύΠϥ࠷దԽͷঢ়گΛ֬ೝ͢ΔʹHDqBHTΛ͍·͢ɻ -gcflags Ὂ
QBHF ͞ΒʹڧྗͳJOMJOJOH͕(P͔ΒೖͬͯΔ IUUQTEPDTHPPHMFDPNQSFTFOUBUJPOE8DCMQKQGF,X":'0NK18.@RN/RM2L/B-K1PFEJUTMJEFJEQ Mid Stack inlining Ὂ
QBHF Conclusion \
QBHF (Pʹ͓͚ΔϕϯνϚʔΫ؆୯ʹऔΕΔ͕ɺ͍ํʹҙ͕ඞཁɻ ϕϯνϚʔΫͷڥͷఏࣔ౷Ұ ϕϯνϚʔΫͷ҆ఆੑͷ֬ೝ ͓͔͍͘͠Β͍͍࣌ϕϯνϚʔΫ࣌ͷίϯύΠϥ࠷దԽͷڍಈΛ֬ೝ Conclusion Ὂ
QBHF Additional Talk \
QBHF (P$POGFSFODF'VLVPLB Ͱొஃ͠·͢ʂ
Benchmark and Compiler Optimization In Go Go Un Conference May
27, 2019 @ po3rin