You are previewing Ruby Performance Optimization.
O'Reilly logo
Ruby Performance Optimization

Book Description

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.

Table of Contents

  1. Ruby Performance Optimization
    1. For the Best Reading Experience...
    2. Table of Contents
    3. Early praise for Ruby Performance Optimization
    4. Preface
      1. The Need for Speed
      2. How to Read This Book
      3. Acknowledgments
    5. Chapter 1: What Makes Ruby Code Fast
      1. What Makes Ruby Code Slow
      2. Optimize Memory
      3. Get Into the Performance Mind-set
    6. Chapter 2: Fix Common Performance Problems
      1. Save Memory
      2. Optimize Your Iterators
      3. Write Less Ruby
      4. Takeaways
    7. Chapter 3: Make Rails Faster
      1. Make ActiveRecord Faster
      2. Make ActionView Faster
      3. Takeaways
    8. Chapter 4: Profile
      1. Measure with Ruby-Prof
      2. Visualize with Ruby-Prof Printers
      3. Visualize with KCachegrind (QCachegrind)
      4. Takeaways
    9. Chapter 5: Learn to Optimize with the Profiler
      1. Optimize but Don’t Break
      2. Pick Low-Hanging Fruit
      3. Take a Step Back
      4. Takeaways
    10. Chapter 6: Profile Memory
      1. Detect Excessive Memory Usage
      2. Profile Memory with Ruby-Prof
      3. Measure Memory Yourself with GC#stat and GC:: Profiler
      4. Takeaways
    11. Chapter 7: Measure
      1. Minimize External Factors
      2. Make Internals Behave Predictably
      3. Analyze and Compare Measurements Using Statis tics
      4. Takeaways
    12. Chapter 8: Test Performance
      1. Benchmark
      2. Assert Performance
      3. Report Slowdowns and Optimizations
      4. Test Rails Application Performance
      5. Takeaways
    13. Chapter 9: Think Outside the Box
      1. Cycle Long-Running Ins tances
      2. Fork to Run Heavy Jobs
      3. Do Out-of-Band Garbage Collection
      4. Tune Your Database
      5. Buy Enough Resources for Production
      6. Takeaways
    14. Chapter 10: Tune Up the Garbage Collector
      1. Understand How Ruby Uses Memory
      2. Know What Triggers GC
      3. Understand Why GC in Ruby 2.1 and 2.2 Is So M uch Faster
      4. Tune Up GC Settings
      5. Takeaways
      6. Onward!
      7. You May Be Interested I n…