Ruby Performance Optimization: Why Ruby is Slow, and How to Fix It (Paperback)

Alexander Dymo

  • 出版商: Pragmatic Bookshelf
  • 出版日期: 2015-12-29
  • 售價: $1,260
  • 貴賓價: 9.5$1,197
  • 語言: 英文
  • 頁數: 202
  • 裝訂: Paperback
  • ISBN: 1680500694
  • ISBN-13: 9781680500691
  • 相關分類: Ruby
  • 立即出貨 (庫存 < 3)

買這商品的人也買了...

商品描述

You don't have to accept slow Ruby or Rails performance. In this comprehensive guide to Ruby optimization, you'll learn how to write faster Ruby code--but that's just the beginning. See exactly what makes Ruby and Rails code slow, and how to fix it. Alex Dymo will guide you through perils of memory and CPU optimization, profiling, measuring, performance testing, garbage collection, and tuning. You'll find that all those "hard" things aren't so difficult after all, and your code will run orders of magnitude faster.

This is the first book ever that consolidates all the Ruby performance optimization advice in one place. It's your comprehensive guide to memory optimization, CPU optimization, garbage collector tuning, profiling, measurements, performance testing, and more.

You'll go from performance rookie to expert. First, you'll learn the best practices for writing Ruby code that's easy not only on the CPU, but also on memory, and that doesn't trigger the dreaded garbage collector. You'll find out that garbage collection accounts for 80% of slowdowns, and often takes more than 50% of your program's execution time. And you'll discover the bottlenecks in Rails code and learn how selective attribute loading and preloading can mitigate the performance costs of ActiveRecord.

As you advance to Ruby performance expert, you'll learn how profile your code, how to make sense out of profiler reports, and how to make optimization decisions based on them. You'll make sure slow code doesn't creep back into your Ruby application by writing performance tests, and you'll learn the right way to benchmark Ruby.

And finally, you'll dive into the Ruby interpreter internals to really understand why garbage collection makes Ruby so slow, and how you can tune it up.

What You Need:

Some version of Ruby. The advice from this book applies to all modern Ruby versions from 1.9 to 2.2. 80% of the material will also be useful for legacy Ruby 1.8 users, and there is 1.8-specific advice as well.

商品描述(中文翻譯)

你不必接受緩慢的Ruby或Rails性能。在這本全面指南中,你將學習如何撰寫更快的Ruby代碼,但這只是開始。了解Ruby和Rails代碼變慢的原因,以及如何修復它。Alex Dymo將引導你通過內存和CPU優化、分析、測量、性能測試、垃圾回收和調整的危險。你會發現,所有這些“困難”的事情其實並不那麼困難,你的代碼將運行得更快。

這是第一本將所有Ruby性能優化建議整合在一起的書籍。它是你全面指南,包括內存優化、CPU優化、垃圾回收器調整、分析、測量、性能測試等等。

你將從性能新手成為專家。首先,你將學習撰寫對CPU和內存都較輕的Ruby代碼的最佳實踐,並且不會觸發可怕的垃圾回收器。你會發現垃圾回收佔慢速的80%,並且通常佔程序執行時間的50%以上。你還將發現Rails代碼中的瓶頸,並學習如何通過選擇性屬性加載和預加載來減輕ActiveRecord的性能成本。

當你成為Ruby性能專家時,你將學習如何分析代碼,如何理解分析器報告,以及如何根據它們做出優化決策。通過撰寫性能測試,你將確保緩慢的代碼不會再次出現在你的Ruby應用程序中,並且你將學習正確的基準測試Ruby的方法。

最後,你將深入研究Ruby解釋器的內部,真正理解為什麼垃圾回收使Ruby變得如此緩慢,以及如何進行調整。

你需要什麼:

某個版本的Ruby。本書的建議適用於從1.9到2.2的所有現代Ruby版本。80%的內容對於舊版Ruby 1.8的用戶也有用,並且還提供了1.8特定的建議。