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
Ruby应用性能调优实践
Search
Li Zhe
October 12, 2015
Programming
10
600
Ruby应用性能调优实践
了解Ruby的性能调优关键,以及都有哪些工具可以利用
Li Zhe
October 12, 2015
Tweet
Share
Other Decks in Programming
See All in Programming
リアルタイムレイトレーシング + ニューラルレンダリング簡単紹介 / Real-Time Ray Tracing & Neural Rendering: A Quick Introduction (2025)
shocker_0x15
1
270
国漢文混用体からHolloまで
minhee
1
140
Unlock the Potential of Swift Code Generation
rockname
0
210
Denoでフロントエンド開発 2025年春版 / Frontend Development with Deno (Spring 2025)
petamoriken
1
1.3k
マルチアカウント環境での、そこまでがんばらない RI/SP 運用設計
wa6sn
0
690
custom_lintで始めるチームルール管理
akaboshinit
0
200
SLI/SLOの設定を進めるその前に アラート品質の改善に取り組んだ話
tanden
3
800
Java 24まとめ / Java 24 summary
kishida
3
400
DomainException と Result 型で作る型安全なエラーハンドリング
karszawa
0
860
Firebase Dynamic Linksの代替手段を自作する / Create your own Firebase Dynamic Links alternative
kubode
0
220
コンテナでLambdaをデプロイするときに知っておきたかったこと
_takahash
0
170
Day0 初心者向けワークショップ実践!ソフトウェアテストの第一歩
satohiroyuki
0
790
Featured
See All Featured
Done Done
chrislema
183
16k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
118
51k
Optimizing for Happiness
mojombo
377
70k
The Pragmatic Product Professional
lauravandoore
33
6.5k
A Modern Web Designer's Workflow
chriscoyier
693
190k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.4k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
8
720
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Music & Morning Musume
bryan
46
6.4k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.5k
How to Think Like a Performance Engineer
csswizardry
22
1.5k
Transcript
Rubyଫአᚆ᧣սਫ᪢ ߽ - OneAPM 2015.10.10
ञฎՋԍҘ
ञ: ݰԧ੪ : ݰԧ੪ݺ
֦మݰᗤᶟҘ ඓԀஞހҘ ౯݄ԧᬟѺ
ڹݶԪ { ڹݶԪ }
ӳ۹Ոࣁଠ
ৼ֯Ո
۹Ղཛྷୗސ …
ํᅩᔲୟ …
౯ժฎଗՋԍጱ? • OneAPM • ᚆፊഴଘݣ • 2015ଙڡਠ౮Cᣟᩒ • 350Ո •
ᬪ200ՈฎᎸݎ • قࢵԆᥝITउ૱᮷ํړلݪېԪ॒
౯ฎ᧡Ҙ • ߽ • Java 2007 ~ 2010 • Ruby
2011 ~ Now • ፓڹ੪ᘳOneAPM - RubyAgent, Cloud Insight • github.com/markgeek • douban.com/people/markgeek/
౯ժᘱᘱRails ౌ ᬯկԪ
ᘏฎRack ౌ ᬯկԪ
ٌਫฎRuby ౌ ᬯկԪ
֦ᦊԅRubyౌހҘ ౌጱᤒሿฎՋԍҘ ፥ጱฎ᭜౮ጱހҘ ᦶ፳አૡٍ༄ၥᬦހҘ
30%զӤጱౌฎຝӤ᧣սጱ
– ӧᎣ᭲ฎ᧡᧔ጱ “ᑕଧާ᮷ฎࡅෛܵ෯ጱਹվ̶”
ӞӻRubyଫአ • 2000ଚݎ • क़᮱ߥଫᳵ300ms • ଫአߥଫᳵ < 150ms •
4ݣԆ / 8core,8G • nginx, goliath, grape, redis
None
None
፡፡RubyጱचᏐܲݥ
RubyVMጱݎܲݥ • 1.9 Koichi Sasada : YARV • 1.9 Narihiro
Nakamura ғLazySweep • 2.0 Narihiro Nakamura ғBitmap Marking GC • 2.1 Koichi Sasada ғGenerational Collector • 2.2 Koichi Sasada ғIncremental Generational Collector
http://tmm1.net/ruby21-rgengc
Rubyጱᬩᤈ᭛ଶӞፗࣁ܋
ӞԶच༷ஷ • Benchmark • Profiling • Tracing • Debugging
Benchmarkғ᪒ړ
benchmark, benchmark-ips
Profilingғᦕ୯ᬩᤈמ௳
None
RubyProf,StackProf
Tracingғᦕ୯ොဩ᧣አמ௳
rbtrace,allocation_tracer
Ӟӻੜጱbenchmark
Ruby Performance
1.98 / 1.14 = 1.7368…
None
RubyProf • flat - Prints a flat profile as text
(default). • dot - Prints a graph profile as a dot file • call_stack - prints a HTML visualization of the call tree • call_tree - format for KCacheGrind
None
None
None
None
StackProf • CPUཛྷୗ • ړᯈཛྷୗ • middlewareཛྷୗ
None
None
None
rbtrace • rbtrace -p <PID> —firehose • rbtrace -p <PID>
—slow=<N> • rbtrace -p <PID> --methods "Kernel#sleep" “Proc#call" • rbtrace -p <PID> --gc
Ꮯਧኒ᷀ԏݸ • fast-ruby • fasterer
Ӟӻਫᴬጱֺৼ
None
None
ݚक़ጱӞԶૡٍ
http://rbkit.codemancers.com/
https://github.com/peek/peek-rblineprof
https://github.com/MiniProfiler/rack-mini-profiler
ইຎ֦ବ੶உఽي᪁ Dtrace / SystemTap
ݳᭇጱૡٍ؉ݳᭇጱૡ֢
Rubyਖ਼տᬩᤈጱๅள
– Yukihiro 'Matz' Matsumoto “Super Dry Ruby”
https://www.youtube.com/watch?v=bqWBB8-iEac&list=PLE7tQUdRKcyZdMYKatu_nics8Pkjxl3-F
ই֜೮ᖅጱፊഴଫአ ጱᚆᳯ᷌
Application Performance Monitor or Application Performance Management
None
None
ӧՐՐฎᬯԶ
None
None
რᩒრ • https://github.com/JuanitoFatas/fast-ruby • https://github.com/DamirSvrtan/fasterer • https://github.com/schneems/derailed_benchmarks • https://github.com/change/method_profiler •
https://github.com/schneems/heapy • https://github.com/peek/peek-rblineprof • https://github.com/tmm1/rblineprof
݇ᘍᩒා1 • https://engineering.heroku.com/blogs/2015-02-04-incremental-gc/ • http://tmm1.net/ruby21-rgengc/ • https://www.youtube.com/watch?v=nRehkd22j78&spfreload=10 • https://avsej.net/2012/systemtap-and-ruby-20/ •
https://www.shopify.com/technology/16777156-tuning-rubys-global-method-cache • https://www.youtube.com/watch?v=pZ_BcEcFGj0 • http://www.atdot.net/~ko1/activities/2015_railsconf.pdf • http://samsaffron.com/archive/2013/11/22/demystifying-the-ruby-gc
݇ᘍᩒා2 • http://www.theirishpenguin.com/2009/10/29/understanding-how-ruby-stores- objects-in-memory-the-ruby-heap.html • http://samsaffron.com/archive/2013/11/22/demystifying-the-ruby-gc • http://thorstenball.com/blog/2014/03/12/watching-understanding-ruby-2.1- garbage-collector/
https://github.com/mattbaker/ruby-heap-viz
ᨀᨀ Q&A