Posts Tagged ‘maglev’

Maglev hype train derailed at last

Saturday, November 21st, 2009

Ah, Maglev. It seems that only yesterday I was ripped to shreds by a furious mob for daring to question your public claims of drastic speed gains over every other Ruby interpreter.

And so imagine my delight today, when the first alpha release is finally available! Sure, it’s only an alpha release, so it’s not going to be quite as good as the final product – but surely it will live up to the claims in the RailsConf 2008 demonstration? I mean, it was that good even then! Surely it must be even better now!

Anyway, I obviously had to install it and put these claims to the test.

I followed the instructions on this page – with a couple of changes, such as that I use .profile instead of .bashrc.

I decided to test with as close to a real world library as I could. That post mentions that Maglev supports Sinatra, so I thought that would be an ideal test. Then again, it also says it supports RubyGems but I couldn’t get that to work at all. C extensions are out too, so we’ll be using Webrick.

To get around the RubyGems problem, I manually downloaded Rack and Sinatra and placed the contents of their lib directories into a single folder. I then created a trivial sinatra app as shown:

require File.expand_path(::File.dirname(__FILE__)) + '/sinatra.rb'
require File.expand_path(::File.dirname(__FILE__)) + '/rack.rb'
 
get '/' do
  "Maglev Rocks!"
end

I decided to run good old ab against it. My exact command was:

ab -kc 10 -t 10 http://127.0.0.1:4567/

Because I have other servers installed in Ruby 1.8.7 and 1.9.1, I forced sinatra to serve using webrick as follows:

ruby1.9 testmaglev.rb -s webrick

Considering the past hype of order-of-magnitude speed hikes, I was ready to be blown away. Are you ready to be blown away? Oh yeah baby, 50 times faster comin’ right up!

RESULTS

Ruby 1.8.7: Requests per second: 131.38 [#/sec] (mean)
Ruby 1.9.1: Requests per second: 144.77 [#/sec] (mean)
Maglev: Requests per second: 97.78 [#/sec] (mean)

Well golly gosh. Look at that. It’s not faster after all – in fact it’s climbing the same steep performance hill ever other interpreter has had to climb, Smalltalk magic notwithstanding. How about that.

I said the benchmarks shown at RailsConf were bullshit and would not even remotely reflect the real world performance of the final product. I said that until the interpreter implemented all of ruby, it was not ruby, and it was worthless to measure its performance. I poured skepticism upon the notion that a new interpreter, just by dint of some doubtfully superior Smalltalk heritage, could leapfrog all previous contenders with a two-order-of-magnitude performance boost.

Looks like I was right. But don’t take my word for it, run the tests yourself. I will be accepting contrite apologies in comments … ;)

Maglev and the naiivety of the Rails community

Monday, June 2nd, 2008

UPDATE: Corrected a couple of typos. Didn’t correct the spelling error in the title because I am enjoying being ranked #1 in a search for the misspelled “naivety”.

I would like to point out also that this is a rant about vapourware and miserably unmet standards of proof – the benchmarks at RailsConf are worthless and prove nothing, but I would dearly love to be wrong.

And also note that I said I consider a dramatically faster Ruby interpreter/VM impossible until conclusively proven otherwise. I didn’t say completely impossible; I hope it is in fact possible to speed up Ruby by 10x or more. It seems unlikely, very unlikely, but who knows. I am in no way an expert on these things, and do not claim to be; I am only reacting to their hype-filled presentation, and drawing comparisons to the recent history of everyone else’s experiences writing Ruby interpreters sans the 60x speedup.

The demonstration at Railsconf was useless, empty hype, and until extraordinary proof is presented, I will remain deeply skeptical of these extraordinary claims.


So there’s been some presentation at Railsconf 2008 about a product called “Maglev“, which is supposedly going to be the Ruby that scales™ (yes, they actually use the trade mark). This new technology is going to set the Ruby world on fire, it’s going to be the saving grace of all Rails’ scaling problems. It’s going to make it effortless to deploy any size Rails site. Its revolutionary shared memory cache is going to obsolete ActiveRecord overnight. It runs up to 60x faster than MRI. And it’s coming Real Soon Now.

Every rails blogger and his dog have posted breathless praise for the new saviour:

Slashdot | MagLev, Ruby VM on Gemstone OODB, Wows RailsConf
RailsConf 2008 – Surprise of the Day: Maglev
MagLev is Gemstone/S for Ruby, Huge News
MagLev rocks and the planning of the next Ruby shootout

So what’s the problem? Why am I being such a party pooper and raining on the new Emperor’s parade?

Because these claims are absolute bullshit and anyone with a hint of common sense should be able to see that.

Right now, there are about 5 serious, credible, working Ruby implementations – MRI, YARV, JRuby, Rubinius, and IronRuby. They all have highly intelligent, experienced, dedicated staff who know a lot more about writing interpreters and VMs than I could ever hope to learn.

So do you seriously think that all these smart people, writing (and collaborating on) all these projects have somehow missed the magic technique that’s going to make Ruby run 60x faster?

It’s definitely possible to get a 2x speedup over MRI and retain full compatibility – Jruby and YARV have shown us that. Maybe it’s possible to get a 3x or 4x broad-based speedup with a seriously optimised codebase. And sure, a few specific functions can probably be sped up even more.

But a broad 20x, 30x, 50x speedup across the whole language beggars belief. It is a huge technical leap and experience suggests they don’t just suddenly happen all at once. Speed gains are incremental and cumulative, a long race slowly won, not an instant teleport into the future. I’d say it is almost impossible, until spectacularly demonstrated otherwise, for a brand new, fully compatible ruby implementation to be more than two or three times faster than today’s best. Things just don’t work that way. Especially things with such a broad range of smart people working hard on the problem.

Extraordinary claims require extraordinary proof. But what do we get? A couple of benchmarks running in isolation. Who knows what they actually are, how tuned they are, whether they’re capable of doing anything other than running those benchmarks fast (I doubt it). No source. No timetable for the source, or anything else.

The bloggers say “this is not ready yet but when it is .. WOW!”. They’re missing the point. Until this thing is actually running Ruby, it’s not Ruby. Benchmarks on a system which isn’t a full implementation of Ruby are utterly worthless. I can write some routine which messes around with arrays in C which is a hundred times faster than Ruby. I might even be able to stick a parser on the front which accepts ruby-like input and then runs it a hundred times faster. Who cares? If it’s not a full implementation of Ruby, it’s not Ruby. Ruby is a very hard language to implement, it’s full of nuance and syntax which is very programmer-friendly but very speed-unfriendly. Until you factor all of that in, these benchmarks ain’t worth jack.

And wow ..! A shared memory cache! Finally, Rails can cast off that shared-nothing millstone around its neck. Except, of course, that shared-nothing is one of its main selling points and wasn’t everyone all on board that train until ten minutes ago? If you want to share objects use the database, something like that?

Oh yeah, the database! Maglev comes with a built-in OODB which is going to set the world on fire. Except of course that OODBs have been around for decades, and the world is not on fire. If OODBs were the solution to all scaling’s ills then Facebook would be using Caché, not MySQL. Guess which one they’re using.

I actually have problems with the whole premise of OODBs, at least as they apply in web applications. Great, you can persist your Ruby objects directly into the OODB. What happens when you want to access them from, say, anywhere else? What if you want to integrate an erlang XMPP server? What if you need Apache to reach into it? What if you want to write emails straight into it, or read them straight out? What if you want to do absolutely anything at all which isn’t a part of some huge monolithic stack? Web applications are all about well-defined protocols, standard formats, and because of those, heterogeneous servers working in unison. I’ve heard OODBs have some benefits in scientific and other niche uses, but web applications are about the most mixed environment imaginable. If using an OODB is the answer, what was the question?

Oh, you think I’m just an RDBMS-addicted luddite? Hell no. I eagerly follow and embrace advances in non-relational database technology – just look around this site, where I talk about being one of the first (crazy) people to press Couch DB into semi-production use, using TokyoCabinet and Rinda/Tuplespace for distributed hashtables, and how I’d much rather write a map/reduce function than a stupid, ugly, undistributable slow JOIN. But OODBs? Give me a break.

But oh no. Show them one bullshit-laden presentation and the entire Rails community is champing at the bit and selling both kidneys to ditch all previous Ruby implementations and everything they thought they knew about the persistence layer and embrace some questionable closed-source vapourware, from the guys who brought you that previous world-storming web framework Seaside. What’s that, you’ve never heard of Seaside? I wonder why.

This credulity and blind bandwagon-jumping is the single worst thing about the Rails community.