October 2010 Archives

memcache-client vs memcached 2010

Mike Perham published this same shootout about a year ago. I needed this info for the day job. Since then, Mike has released dalli, a Ruby 1.9.2-targeted smaller, tighter memcache-client. So it’s time for Round 2. Fight!

Platform used was MacOSX 10.6.4 on a 3.06 Ghz Core 2 Duo MBP w/ memcached v1.4.5 and running Ruby 1.8.7.

memcached is v1, dalli v0.10.1, and memcache-client v1.8.5.

                                     user     system      total        real
set:plain:memcached              0.170000   0.210000   0.380000 (  0.810570)
set:plain:dalli                  1.680000   0.280000   1.960000 (  2.253942)
set:plain:memcache-client        1.880000   0.290000   2.170000 (  2.299018)

set:ruby:memcached               0.180000   0.210000   0.390000 (  0.814561)
set:ruby:dalli                   1.700000   0.260000   1.960000 (  2.039180)
set:ruby:memcache-client         1.930000   0.290000   2.220000 (  2.294238)

get:plain:memcached              0.180000   0.210000   0.390000 (  0.790628)
get:plain:dalli                  1.750000   0.290000   2.040000 (  2.113645)
get:plain:memcache-client        2.220000   0.300000   2.520000 (  2.695678)

get:ruby:memcached               0.190000   0.210000   0.400000 (  0.791203)
get:ruby:dalli                   1.740000   0.280000   2.020000 (  2.087606)
get:ruby:memcache-client         2.250000   0.300000   2.550000 (  2.613772)

missing:ruby:memcached           0.280000   0.230000   0.510000 (  0.890550)
missing:ruby:dalli               1.670000   0.290000   1.960000 (  2.076984)
missing:ruby:memcache-client     1.850000   0.290000   2.140000 (  2.236749)

mixed:ruby:memcached             0.370000   0.410000   0.780000 (  1.621562)
mixed:ruby:dalli                 3.310000   0.550000   3.860000 (  4.399427)
mixed:ruby:memcache-client       4.170000   0.600000   4.770000 (  5.000441)

We’re looking at almost a factor of 3 in favor of memcached. And both result sets were obtained using Benchmark.bmbm (I love that method name).

And now using Ruby 1.9.2:

set:plain:memcached              0.160000   0.220000   0.380000 (  0.804786)
set:plain:dalli                  1.200000   0.270000   1.470000 (  1.540213)
set:plain:memcache-client        1.440000   0.280000   1.720000 (  1.804081)

set:ruby:memcached               0.160000   0.210000   0.370000 (  0.800606)
set:ruby:dalli                   1.200000   0.270000   1.470000 (  1.537974)
set:ruby:memcache-client         1.530000   0.280000   1.810000 (  1.922806)

get:plain:memcached              0.150000   0.210000   0.360000 (  0.757057)
get:plain:dalli                  1.280000   0.300000   1.580000 (  1.645847)
get:plain:memcache-client        1.690000   0.300000   1.990000 (  2.101135)

get:ruby:memcached               0.160000   0.210000   0.370000 (  0.748016)
get:ruby:dalli                   1.290000   0.320000   1.610000 (  1.679947)
get:ruby:memcache-client         1.710000   0.300000   2.010000 (  2.157334)

missing:ruby:memcached           0.180000   0.210000   0.390000 (  0.790607)
missing:ruby:dalli               1.220000   0.300000   1.520000 (  1.583295)
missing:ruby:memcache-client     1.430000   0.280000   1.710000 (  1.785973)

mixed:ruby:memcached             0.310000   0.410000   0.720000 (  1.552239)
mixed:ruby:dalli                 2.500000   0.600000   3.100000 (  3.238964)
mixed:ruby:memcache-client       3.160000   0.590000   3.750000 (  4.054283)

And now native is only ~ 2x faster than Ruby. Interesting.

Posted by evan on Oct 25, 2010

On Life

http://en.wikipedia.org/wiki/Conway%27sGameof_Life>Conway’s Game of Life, that is. The Game of Life has increasingly become a topic of fascination in Ruby circles since Corey Haines began pushing it as the focial point of his Code Retreats.

In short, GoL it is a cellular automata with emergent properties. Which is to say that they can be nifty to watch once you set one in motion.

However, the point of a Code Retreat is to focus on taking small steps, via Test Driven Development, not so much to build a functioning GoL but more importantly to improve on basic skills.

Facilitating a Code Retreat at Ruby DCamp 2010 cinched my interest in hacking on cellular automata to improve my TDD skills. So, for the past few weeks, I’ve been eeking out time here and there to write a JavaScript GoL. While I’m reasonably pleased with the readability of the initial-outcome code, it’s CPU-intensive and unoptimized.

I went so far as to add support to my Game of Life for Lifewiki Plaintext input late last night in a mostly complete but slightly klugey way. And, unsurprisingly, having a good test suite made this addition trivial. However, for the sake of expediency, I used a Spidermonkey supported XML trick to simulate heredocuments in JavaScript.

Ultimately, I used the exercise as a test bed to further improve my Javascript, to wade deeper into Jasmine (a contemporary JavaScript testing framework), and to get my feet wet with Underscore.js (I don’t know how I’ve lived this long without it…) and Coffeescript.

Feel free to give my Game of Life a run. But run it in Firefox if you want it to work! And, be warned, it will hit your CPU hard. http://evan.tiggerpalace.com/Conway-s-Game-of-Life-in-Javascript/index.html

Posted by evan on Oct 17, 2010