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
コードに語らせよう――自己ドキュメント化が内包する楽しさについて / Let the Code Speak
nrslib
6
1.3k
Spring gRPC で始める gRPC 入門 / Introduction to gRPC with Spring gRPC
mackey0225
2
420
FastMCPでMCPサーバー/クライアントを構築してみる
ttnyt8701
2
120
Perlで痩せる
yuukis
1
670
Perplexity Slack Botを作ってAI活用を進めた話 / AI Engineering Summit プレイベント
n3xem
0
340
20250528 AWS Startupイベント登壇資料:AIコーディングの取り組み
procrustes5
0
140
統一感のある Go コードを生成 AI の力で手にいれる
otakakot
0
540
少数精鋭エンジニアがフルスタック力を磨く理由 -そしてAI時代へ-
rebase_engineering
0
150
人には人それぞれのサービス層がある
shimabox
3
630
SODA - FACT BOOK
sodainc
1
350
Interface vs Types ~型推論が過多推論~
hirokiomote
1
240
try-catchを使わないエラーハンドリング!? PHPでResult型の考え方を取り入れてみよう
kajitack
3
450
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.3k
Fontdeck: Realign not Redesign
paulrobertlloyd
84
5.5k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
22k
Making Projects Easy
brettharned
116
6.2k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
KATA
mclloyd
29
14k
Adopting Sorbet at Scale
ufuk
77
9.4k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Rails Girls Zürich Keynote
gr2m
94
13k
A designer walks into a library…
pauljervisheath
205
24k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
6
670
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