Or how my spec suite runtime went from 11 minutes and 10 seconds to 3 minutes and 29 seconds!
The Rails project I am currently working on is developed using BDD. This means that is has a big, fat spec suite. Or to be more specific it has 10033 examples!
This is very nice except for one thing: It is slooow
On my shiny (literally) new 2.4 GHz MacBook Pro the spec suite has a runtime of 670 seconds ie. 11 minutes and 10 seconds – yikes! This is with the ruby interpreter shipped with Mac OS X Leopard.
I have noticed running top that it seems to be mostly CPU bound. The ruby process hovers at around 95-100% CPU usage.
Ruby Enterprise Edition to the rescue!
Previously, I have tried to run the spec suite with the 1.8.6-20080810 version of REE and it did not change the runtime significantly.
The new 1.8.6-20081205 version has some interesting changes. First of all, the tcmalloc memory allocator now works with Mac OS X. And second of all, it has integration with the RailsBench garbage collector patches which allows for tweaking the GC settings of the ruby interpreter.
So what does mean in “real life”?
I downloaded and installed the new version of REE and ran the spec suite. The runtime with the new REE version was 436 seconds ie. 7 minutes and 16 seconds, chopping of nearly 4 minutes – VERY nice!
RailsBench GC patches to the rescue!
I decided to experiment a little with the GC settings ie.
export RUBY_GC_MALLOC_LIMIT=64000000
and reran the spec suite. The result: 221 seconds ie. 3 minutes and 41 seconds. Tried RUBY_GC_MALLOC_LIMIT=256000000 and the result: 209 seconds ie. 3 minutes and 29 seconds – holy Batman!
Thank you guys!
I suggest you go to workingwithrails.com and recommend Hongli Lai, Ninh Bui and Stefan Kaes like I just did – they deserve it.
If you use fixtures or sql queries much then mysqlplus is a big saver too–if you can find the branch that has “sql automatic garbage collection turned off”
Comment by roger — December 6, 2008 @ 17:23 |
wonder how much of that is attributable to compiling with or without pthreads
Comment by roger — December 6, 2008 @ 17:30 |
Wonder also how speed would be with a ’standard’ ruby built with those preprocessor directives.
Comment by roger — December 14, 2008 @ 04:37 |