Dalli Performance and Garbage Collection

2010-09-19

I did an interesting experiment to compare memcache-client and Dalli performance this morning. I wanted to understand which library allocated more objects in order to know which library would have more GC overhead. Ruby 1.9 has a new module GC::Profiler which will generate a report with stats about each GC run. Since both gems have an identical benchmark suite, I ran the GC Profiler on the benchmark suite for each:

<th>
  Runs
</th>

<th>
  GC Time
</th>

<th>
  Total Time
</th>
<td>
  596
</td>

<td>
  3.40
</td>

<td>
  18.35
</td>
<td>
  153
</td>

<td>
  1.73
</td>

<td>
  15.29
</td>
 
memcache-client
dalli

memcache-client runs the GC 4x as much as Dalli and roughly half of Dalli’s speed improvement over memcache-client is due to more efficient object allocation requiring less garbage collection. Note that Dalli’s GC runs seem to take twice as long as the memcache-client runs. Anyone know Ruby 1.9’s GC implementation and have an idea why this might be?