From 2b384df218365f70f36ccf746d1bffe063ff09a6 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sat, 10 Jan 2009 04:37:14 +0000 Subject: [PATCH] Add a note about tuning perf test runs --- .../doc/guides/html/performance_testing.html | 76 ++++++++++++++----- .../doc/guides/source/performance_testing.txt | 26 +++++-- 2 files changed, 77 insertions(+), 25 deletions(-) diff --git a/railties/doc/guides/html/performance_testing.html b/railties/doc/guides/html/performance_testing.html index ca5070f095..52c2a3599d 100644 --- a/railties/doc/guides/html/performance_testing.html +++ b/railties/doc/guides/html/performance_testing.html @@ -212,6 +212,8 @@ ul#navMain {
  • Understanding the output
  • +
  • Tuning Test Runs
  • +
  • Installing GC Patched Ruby
  • @@ -232,10 +234,17 @@ ul#navMain { Request Logging
  • - Other Profiling Tools + Useful Profiling Tools +
  • - Commercial products + Commercial Products
  • Changelog @@ -514,7 +523,7 @@ http://www.gnu.org/software/src-highlite --> 0.00771250000000012,2009-01-09T15:46:03Z,,2.3.0.master.859e150,ruby-1.8.6.110,i686-darwin9.0.0

    1.5.2. Profiling

    Command line
    -

    This is a very basic form of output in profiling mode. Example :

    +

    This is a very basic form of output in profiling mode:

    Graph

    Graph output shows how long each method takes to run, which methods call it and which methods it calls. Check ruby prof documentation for a better explaination.

    Tree
    -

    Tree output is profiling information in calltree format for use by kcachegrind and similar tools.

    -

    1.6. Installing GC Patched Ruby

    +

    Tree output is profiling information in calltree format for use by kcachegrind and similar tools.

    +

    1.6. Tuning Test Runs

    +

    By default, each performance test is run 4 times in benchmarking model and 1 time in profiling. However, test runs can easily be configured.

    +
    + + + +
    +Caution +That’s a lie. But not for long.
    +
    +

    1.7. Installing GC Patched Ruby

    To get the best from Rails performance tests, you need to build a special Ruby binary with some super powers - GC patch for measuring GC Runs/Time and memory/object allocation.

    The process is fairly straight forward. If you’ve never compiled a Ruby binary before, follow the following steps to build a ruby binary inside your home directory:

    -

    1.6.1. Instllation

    +

    1.7.1. Instllation

    Compile Ruby and apply this GC Patch:

    -

    1.6.2. Download and Extract

    +

    1.7.2. Download and Extract

    [lifo@null ~]$ wget <download the latest stable ruby from ftp://ftp.ruby-lang.org/pub/ruby> [lifo@null ~]$ tar -xzvf <ruby-version.tar.gz> [lifo@null ~]$ cd <ruby-version>
    -

    1.6.3. Apply the patch

    +

    1.7.3. Apply the patch

    [lifo@null ruby-version]$ curl http://rubyforge.org/tracker/download.php/1814/7062/17676/3291/ruby186gc.patch | patch -p0
    -

    1.6.4. Configure and Install

    +

    1.7.4. Configure and Install

    The following will install ruby in your home directory’s /rubygc directory. Make sure to replace <homedir> with a full patch to your actual home directory.

    [lifo@null ruby-version]$ ./configure --prefix=/<homedir>/rubygc
     [lifo@null ruby-version]$ make && make install
    -

    1.6.5. Prepare aliases

    +

    1.7.5. Prepare aliases

    For convenience, add the following lines in your ~/.profile:

    @@ -571,7 +590,7 @@ alias gcgem='~/rubygc/bin/gem' alias gcirb='~/rubygc/bin/irb' alias gcrails='~/rubygc/bin/rails'
    -

    1.6.6. Install rubygems and dependency gems

    +

    1.7.6. Install rubygems and dependency gems

    Download Rubygems and install it from source. Rubygem’s README file should have necessary installation instructions.

    Additionally, installa the following gems :

      @@ -638,7 +657,7 @@ http://www.gnu.org/software/src-highlite --> Note -benchmark it’s a class method inside controllers. +benchmark is a class method inside controllers
    @@ -685,16 +704,12 @@ http://www.gnu.org/software/src-highlite -->

    This data is fairly straight forward to understand. Rails uses millisecond(ms) as the metric to measures the time taken. The complete request spent 5 ms inside Rails, out of which 2 ms were spent rendering views and none was spent communication with the database. It’s safe to assume that the remaining 3 ms were spent inside the controller.

    Michael Koziarski has an interesting blog post explaining the importance of using milliseconds as the metric.

    -

    4. Other Profiling Tools

    +

    4. Useful Profiling Tools

    +

    4.1. Rails Plugins and Gems

    +

    4.2. External

    +
    -

    5. Commercial products

    +

    5. Commercial Products

    Rails has been lucky to have three startups dedicated to Rails specific performance tools:

      diff --git a/railties/doc/guides/source/performance_testing.txt b/railties/doc/guides/source/performance_testing.txt index a21f323f2f..e79311aa12 100644 --- a/railties/doc/guides/source/performance_testing.txt +++ b/railties/doc/guides/source/performance_testing.txt @@ -271,7 +271,7 @@ measurement,created_at,app,rails,ruby,platform ===== Command line ===== -This is a very basic form of output in profiling mode. Example : +This is a very basic form of output in profiling mode: [source, shell] ---------------------------------------------------------------------------- @@ -291,7 +291,13 @@ Graph output shows how long each method takes to run, which methods call it and ===== Tree ===== -Tree output is profiling information in calltree format for use by kcachegrind and similar tools. +Tree output is profiling information in calltree format for use by http://kcachegrind.sourceforge.net/html/Home.html[kcachegrind] and similar tools. + +=== Tuning Test Runs === + +By default, each performance test is run +4 times+ in benchmarking model and +1 time+ in profiling. However, test runs can easily be configured. + +CAUTION: That's a lie. But not for long. [[gc]] === Installing GC Patched Ruby === @@ -392,7 +398,7 @@ Please refer to http://api.rubyonrails.com/classes/ActiveRecord/Base.html#M00133 Similarly, you could use this helper method inside http://api.rubyonrails.com/classes/ActionController/Benchmarking/ClassMethods.html#M000715[controllers] -NOTE: +benchmark+ it's a class method inside controllers. +NOTE: +benchmark+ is a class method inside controllers [source, ruby] ---------------------------------------------------------------------------- @@ -438,13 +444,21 @@ This data is fairly straight forward to understand. Rails uses millisecond(ms) a Michael Koziarski has an http://www.therailsway.com/2009/1/6/requests-per-second[interesting blog post] explaining the importance of using milliseconds as the metric. -== Other Profiling Tools == +== Useful Profiling Tools == + +=== Rails Plugins and Gems === -* http://www.hpl.hp.com/research/linux/httperf/[httperf] * http://rails-analyzer.rubyforge.org/[Rails Analyzer] * http://www.flyingmachinestudios.com/projects/[Palmist] +* http://github.com/josevalim/rails-footnotes/tree/master[Rails Footnotes] -== Commercial products == +=== External === + +* http://www.hpl.hp.com/research/linux/httperf[httperf] +* http://httpd.apache.org/docs/2.2/programs/ab.html[ab] +* http://jakarta.apache.org/jmeter[JMeter] + +== Commercial Products == Rails has been lucky to have three startups dedicated to Rails specific performance tools: