Playin' with the Ruby GC

So I, like many of you geeks out there heard about the changes to Ruby in 1.9.3-rc1. Upon hearing the news, I hurriedly scanned the intra-webz to see if there were any cool features that would affect me or my production apps. Some of the changes in the release candidate were pleasantly surprising, especially file loading (which saw a notable ~38% speed boost). When I saw the garbage collector was being changed to something called "Lazy Sweeping" I had to figure out how much this was going to impact performance. I mean c'mon "lazy sweeping", sounds so interesting right? So I started writing a script to tell me just that.

Let's start this in reverse order.

The results

I found that the the new "lazy sweeping" (still super cool name) was about 8% faster on average. Here's the pretty graph I created from Excel.

gc graph

The vertical axis is the time in milliseconds, and the horizontal axis represents the GC cycle during the creation of ~10,000 objects. Alright alright alright. I'll explain the methodology so you can actually understand the graph.

The Methodology

While doing the research I came across a nifty little script by the Narihiro Nakamura here. I modified it slightly, but kept the same idea of creating a number of objects to fill up the heap.