Saturday, March 26, 2011

Ruby and Protocol Buffers, Take One and a Half

In a comment on my previous post on Protocol Buffers, Clayton O'Neill recommended trying out the java protobuf library with jruby. I'll get to that eventually, but his comment made me wonder how jruby and rubinius would do with this little test.
I fired up rvm and looped through my installed versions. Here are the results:
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-linux]
real 3m11.857s
user 3m11.024s
sys 0m0.124s
jruby 1.5.5 (ruby 1.8.7 patchlevel 249) (2010-11-10 4bd4200) (Java HotSpot(TM) Client VM 1.6.0_24) [i386-java]
real 2m54.035s
user 2m53.355s
sys 0m0.388s
rubinius 1.1.1 (1.8.7 release 2010-11-16 JI) [i686-pc-linux-gnu]
real 1m59.693s
user 2m5.292s
sys 0m0.148s
ruby 1.9.1p378 (2010-01-10 revision 26273) [i686-linux]
real 1m50.293s
user 1m49.811s
sys 0m0.092s
I certainly wouldn't choose a ruby implementation based on this alone, but it's good to see where things stand at the get go. As I keep going with this exploration, I'll try to keep posting timing results.

Update: Evan Phoenix (@evanphx) pointed out that I was using old versions of Rubinius and JRuby. Since I'm boxed into which Ruby implementation I use (1.8.7 on our boxes at work), I wasn't thinking about keeping things up to date in my RVM installation. I've updated JRuby and Rubinius and rerun the test. The results are as follows:
jruby 1.6.0 (ruby 1.8.7 patchlevel 330) (2011-03-15 f3b6154) (Java HotSpot(TM) Server VM 1.6.0_24) [linux-i386-java]
real 1m38.390s
user 1m42.914s
sys 0m0.508s
rubinius 1.2.4dev (1.8.7 536a6eb8 yyyy-mm-dd JI) [i686-pc-linux-gnu]
real 1m58.138s
user 2m1.492s
sys 0m0.144s


Unknown said...

Hi Pat,

If you want to use this to figure out which implementation to use, I suggest you at least try with the latest versions. Specifically, Rubinius 1.1.1 is a bit old as we're on 1.2.3 now.

- Evan

gnupate said...

Hi Evan,
good point. I'm installing the newest rubinius with rvm now. I'll update the post shortly.

Unknown said...

I hate to nit pick, but any chance you could wrap the whole thing in Benchmark.measure {} instead of using unix time? In the Rubinius case, you're seeing multiple threads worth of time due to the JIT (meaning time can run at 2x wall clock).

gnupate said...

It's actually already using Benchmark.measure. I'm just timing the 10 runs of ruby-protobuf and ruby-protocol-buffer (and the accompanying analysis) so I could see the elapsed wall clock time.

I'll put together a version that uses Benchmark, but not tonight. ;)

Unknown said...

Ah ok! Your output looks exactly like time's output, thus my confusion.