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
780
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
M3におけるCI/CDパイプラインを新鮮に保つ仕組み
po3rin
0
280
Go Templateを使った フロントエンド開発を採用した 経緯と所感
po3rin
0
290
検索基盤移行時の思考
po3rin
0
4.2k
Go1.19で採用された Pattern-defeating Quicksort の紹介
po3rin
7
5.6k
Elasticsearchを負荷から守るesguard
po3rin
0
240
Sudachi×Elasticsearchへの移行と医療検索システム精度改善
po3rin
1
840
eskeeperを使ったファイル定義によるindex管理
po3rin
2
450
M3 情報検索/推薦論文輪読会 ~SIGIR祭~ (SIGIR2021: Session 6D – IR Models)
po3rin
0
82
Handling Temporal Query for Health Search with ja-timex
po3rin
3
310
Other Decks in Programming
See All in Programming
Security_for_introducing_eBPF
kentatada
0
110
Haze - Real time background blurring
chrisbanes
1
510
良いユニットテストを書こう
mototakatsu
5
2k
複雑な仕様に立ち向かうアーキテクチャ
myohei
0
170
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
770
DevFest Tokyo 2025 - Flutter のアプリアーキテクチャ現在地点
wasabeef
5
900
HTTP compression in PHP and Symfony apps
dunglas
2
1.7k
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
130
return文におけるstd::moveについて
onihusube
1
950
fs2-io を試してたらバグを見つけて直した話
chencmd
0
220
たのしいparse.y
ydah
3
120
ソフトウェアの振る舞いに着目し 複雑な要件の開発に立ち向かう
rickyban
0
890
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
For a Future-Friendly Web
brad_frost
175
9.4k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
Raft: Consensus for Rubyists
vanstee
137
6.7k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Docker and Python
trallard
42
3.1k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Writing Fast Ruby
sferik
628
61k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
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