SlideShare une entreprise Scribd logo
1  sur  79
Télécharger pour lire hors ligne
Powered by Rabbit 2.1.8
Rubyのパフォーマンスは
どこまで上げられるか。
あるいはRubyは
本当に遅いのか?
Rubyアソシエーション 理事長
ネットワーク応用通信研究所
Heroku
まつもとゆきひろ
@yukihiro_matz
Yukihiro "Matz" Matsumoto
Powered by Rabbit 2.1.8
 
Railsアプリ開発経験
Powered by Rabbit 2.1.8
 
ゼロ (or 1)
Powered by Rabbit 2.1.8
 
Rubyは本当に遅いのか
Powered by Rabbit 2.1.8
 
「遅い」を定義せよ
Powered by Rabbit 2.1.8
 
エンジニアは感覚と勘で
仕事してはいけない
Powered by Rabbit 2.1.8
 
Premature optimization is the
root of all evil
Donald Knuth
Powered by Rabbit 2.1.8
 
早すぎる最適化は諸悪の根源
ドナルド・クヌース
Powered by Rabbit 2.1.8
 
どの程度速い必要があるか
Powered by Rabbit 2.1.8
 
どの程度コストをかけられるか
Powered by Rabbit 2.1.8
 
生産性が重要
Powered by Rabbit 2.1.8
 
最重要は「たのしいプログラミング」
Powered by Rabbit 2.1.8
 
パフォーマンス最重要は昔の話
Powered by Rabbit 2.1.8
 
たのしく(速く)開発して
Powered by Rabbit 2.1.8
 
必要最低限速くする
Powered by Rabbit 2.1.8
 
パフォーマンスチューニングの鉄則
Powered by Rabbit 2.1.8
 
パレートの法則
Powered by Rabbit 2.1.8
 
80:20則
Powered by Rabbit 2.1.8
 
実行時間の8割は
2割の部分で消費される
Powered by Rabbit 2.1.8
 
実行時間の5%占める部分を
超高速化しても全体は
95%にしかならない
Powered by Rabbit 2.1.8
 
ボトルネックしか意味がない
Powered by Rabbit 2.1.8
 
エンジニアは感覚と勘で
仕事してはいけない
Powered by Rabbit 2.1.8
 
パフォーマンスチューニングの鉄則2
Powered by Rabbit 2.1.8
 
測定
Powered by Rabbit 2.1.8
 
数値
Powered by Rabbit 2.1.8
 
遅くなる様々な要素
Powered by Rabbit 2.1.8
 
処理系の遅さ(Rubyの遅さ)
Powered by Rabbit 2.1.8
 
アルゴリズムの遅さ
Powered by Rabbit 2.1.8
 
データベースの遅さ
Powered by Rabbit 2.1.8
 
メモリの遅さ
Powered by Rabbit 2.1.8
 
GCの遅さ
Powered by Rabbit 2.1.8
 
測定
Powered by Rabbit 2.1.8
 
数値
Powered by Rabbit 2.1.8
 
原因が明らかなら解決は
(比較的)簡単
Powered by Rabbit 2.1.8
 
パフォーマンスチューニングの鉄則3
Powered by Rabbit 2.1.8
 
まずアルゴリズムを検討
Powered by Rabbit 2.1.8
 
その他の改善手段とは
桁(オーダー)が違う
Powered by Rabbit 2.1.8
 
O(ビッグ・オー)記法
Powered by Rabbit 2.1.8
 
O(n^2)
Powered by Rabbit 2.1.8
 
O(n・log(n))
Powered by Rabbit 2.1.8
 
O(1)
Powered by Rabbit 2.1.8
 
パフォーマンスチューニングの鉄則4
Powered by Rabbit 2.1.8
 
自分で仕事しない
Powered by Rabbit 2.1.8
 
ライブラリルーチンに任せる
Powered by Rabbit 2.1.8
 
Rubyのライブラリコードは
最適化されてる(ことが多い)
Powered by Rabbit 2.1.8
 
Cで実装されているものも多い
Powered by Rabbit 2.1.8
 
自分でCで実装するよりも
工夫されてる(≒高速)
Powered by Rabbit 2.1.8
 
パフォーマンスチューニングの鉄則5
Powered by Rabbit 2.1.8
 
オブジェクトアロケーションを避ける
Powered by Rabbit 2.1.8
 
メモリ問題
Powered by Rabbit 2.1.8
 
GC問題
Powered by Rabbit 2.1.8
 
文字列リテラル
Powered by Rabbit 2.1.8
 
部分文字列
Powered by Rabbit 2.1.8
 
コピーを避ける
Powered by Rabbit 2.1.8
 
例:長い文字列
Powered by Rabbit 2.1.8
 
正規表現+インデックス
vs
部分文字列
Powered by Rabbit 2.1.8
 
ボトルネックに限定する
Powered by Rabbit 2.1.8
 
パフォーマンスチューニングの鉄則6
Powered by Rabbit 2.1.8
 
新しいRubyを使う
Powered by Rabbit 2.1.8
 
2.2
Powered by Rabbit 2.1.8
 
2.3
Powered by Rabbit 2.1.8
 
0.1ごとに5〜10%改善
Powered by Rabbit 2.1.8
 
金利より高い率
Powered by Rabbit 2.1.8
 
GCの改善
Powered by Rabbit 2.1.8
 
メモリアロケーションの改善
Powered by Rabbit 2.1.8
 
メソッド呼び出しの改善
Powered by Rabbit 2.1.8
 
高い互換性
Powered by Rabbit 2.1.8
 
まとめ
Powered by Rabbit 2.1.8
 
高速化は目的じゃない
Powered by Rabbit 2.1.8
 
まず測定する
Powered by Rabbit 2.1.8
 
ボトルネックを見つける
Powered by Rabbit 2.1.8
 
より良いアルゴリズムを検討
Powered by Rabbit 2.1.8
 
自分で仕事しない
Powered by Rabbit 2.1.8
 
オブジェクトアロケーションを避ける
Powered by Rabbit 2.1.8
 
新しいRubyを使う
Powered by Rabbit 2.1.8
 
パフォーマンスチューニングは楽しい
Powered by Rabbit 2.1.8
 
目的を見失う
Powered by Rabbit 2.1.8
 
CRubyコア開発へようこそ
Powered by Rabbit 2.1.8
 
ありがとうございました1

Contenu connexe

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Rubyのパフォーマンスはどこまで上げられるか。あるいはRubyは本当に遅いのか?