torsdag, april 26, 2007

JRuby at TheServerSide Java Symposium - Europe

Not sure if I've mentioned this, but I will represent JRuby at TheServerSide Java Symposium - Europe, in Barcelona, June 27-29. I will give one technical session on JRuby, and one BOF on how to deploy JRuby on Rails applications, both which should be quite exciting.

There are also a number of other nice presentations, so try to get to Barcelona!

Ye Zheng joins ThoughtWorks

Sorry if the title gives it away. I've been holding quiet about this for almost a month, but now it's official. Ye Zheng (more famous as dreamhead), who is one of the core developers of XRuby, have joined ThoughtWorks, and will begin work in China in May. He will be much involved in all things Ruby, and will also work on XRuby and JRuby, so we will probably be working close together. I have the highest respect for Ye Zheng and look forward to working with him. He single handedly rewrote most of the runtime in XRuby for the last release, which is not a small feat.

If you read Chinese, you can read more about it at his blog at

tisdag, april 24, 2007

JRuby 0.9.9 released

The JRuby team is happy to announce that 0.9.9 has now been released. This release have seen much focus on compatibility with Ruby 1.8, and also making the Java Integration features more solid. We are gearing up for a 1.0-release, and 0.9.9 should be pretty close to what you can expect from 1.0, so now is the time to start testing your applications on JRuby in earnest.


Some of the most important points of this release:
  • Major compatibility and performance overhaul of String, Array, Hash
  • Many YAML and Marshalling issues have been fixed
  • Java Integration overhaul fixing many outstanding issues
  • 180 Jira issues resolved
  • Several more bottlenecks removed
  • Rails applications like Mephisto and plugins like Goldberg are running without hitches
  • Performance has improved by 40% over 0.9.8 based on YARV benchmarks
In response to all the things that needs doing before 1.0, we have decide to add two new committers to the team. Marcin Mielżyński and Bill Dortch have both done some incredibly nice things for the JRuby project, and we're very happy about them joining up as core developers.

In conjunction with 0.9.9, Rails-integration will see a new release, that improves many parts of it. Since we've actually started using Rails-integration in more places, we have also noticed things that need to be improved; the new release is very good.

ActiveRecord-JDBC 0.2.4 will also be released very soon. We have made some major changes, and much of the core have been rewritten. These changes make MySQL fully compatible with ActiveRecord, and we are working hard on improving support for other databases. Hopefully, the 0.2.4 release will mean Derby support is more or less complete too.

fredag, april 20, 2007

Practical JRuby on Rails

The time of waiting is over. I have hinted over and over that I've been doing some stuff that take lots of time. The first part of this was interviewing for ThoughtWorks, and I told you that a month back. And now I can finally tell you what's keeping me so busy, that I can't blog as much as I used to:

I am writing Practical JRuby on Rails: Web 2.0 projects for APress. I have been since late December, and the book is due to be published in October. But you can actually preorder the book today, from Amazon, here.

söndag, april 15, 2007

Me presenting JRuby

I totally forgot about this; 4-6 weeks ago, I did a presentation for the local Railsgroup here in Stockholm; since Dr Nic was there, I decided to improve it in English. And Dr Nic did us the service of taping the whole presentation; I was sick at the time, it's a short presentation about what's new in JRuby, but it could still be potentially interesting for some of you.

It's available at Google Video, here.

fredag, april 13, 2007

The State of JRuby

It's been sort of quiet on the JRuby front for a few weeks, so I thought I'd give a heads up on what things we're working on at the moment. At the moment, we're planning to release 0.9.9 sometime next week. At that point, several things we're working on right now should be fixed.
  • There is a problem with deterministic threading in JRuby, which results in timeout errors sometimes escaping out of their rescue nodes. This is very serious for long running applications and Charles is hard at work providing better Thread semantics for us. The problem is that it's very hard to match MRI's green thread functionality with real native threads.
  • Thomas is hard at work with one of his gigantic refactorings. This time the goal is to remove most of ThreadContext and make many parts of the call chain and block invocation chains easier to work with.
  • Marcin have been working for some weeks now on a port of the hash implementation in MRI, and a corresponding rewrite of RubyHash. At the same time, he's hard at work rewriting RubyString to allow COW (copy-on-write) semantics. This could potentially improve performance and also make JRuby less memory intense.
  • Earlier this week, we identified and fixed two very serious memory leaks. The second of these caused large leakage in all Rails applications using Cgi::Session for session data (which is almost all JRuby on Rails applications, except those running in Rails-integration). At the moment we don't see any leaking for Rails applications, so the situation looks good. (Both of these leaks were found with the help of Java monitoring tools, like JConsole, jmap and jhat. Very useful things.)
  • I have been doing some serious YAML fixes these last days, with the result that our YAML situation is better than ever. It even handles recursive objects correctly. (Which is a pain in Java. In C it's easy, though.)
Overall, we're working very hard on the last, quirky compatibility issues right now; we have a few different, large Rails applications that we use to identify strange issues. And also, more and more people are trying their applications on JRuby, which means we get better (and more) bug reports. This is really great.

After 0.9.9 has been released, we're planning on finishing up remaining important bugs. I'm also very keen about getting more databases running really well with Rails. We will try to get Continous Integration set up for these too.

ActiveHibernate - Any takers?

This is a call for action. JRuby on Rails is getting more stable each day, and JRuby performance is consistently improving. This means that JRuby on Rails is well on the path of becoming a viable platform for several kinds of web development.

ActiveRecord-JDBC is central to this, and it's a good project and works very well. Within the limitations of ActiveRecord, of course. So, I'm thinking (and this is by all means not a new thought), that I would like to have the rest of Rails, but using Hibernate as backend. With JRuby approaching 1.0 fast, ActiveHibernate seems like a neat project. The only problem is time. So why is ActiveHibernate tempting? Well, for all those situations where ActiveRecord really doesn't fit; composite keys, complicated legacy systems. Or databases where you would like to use prepared statements for everything. Or get really nice speed.

What needs to be done? For it to be really useful, there are few points: First, a Hibernate extension that serializes and deserializes into RubyObjects. By doing it that way, there is no need to create Java bean classes. Secondly, provide all the useful help functionality around the Hibernate implementation, that AR users have gotten used to. This includes things like validations, automatic handling of updates and inserts, and is generally about doing a good Ruby interface around Hibernate. This also includes creating a good way of configuring Hibernate without having to resort to the XML. Maybe using YAML? Or a Ruby DSL? After that has been done, the final point is easy: get mind share and start doing applications with it! I for one know that I would like to use such a project!

onsdag, april 11, 2007

Can your Ruby do this?

Recipe (should be baked with Java 6 for maximum pleasure):
  1. Take one large Rails application with good Selenium test base
  2. Convert database configuration to use JDBC
  3. Start a selenium proxy with "jake test:selenium_proxy"
  4. Start acceptance testing from another window with "jake test:acceptance"
  5. In yet another window, write "jconsole"
  6. Choose your application
What do you get?

You get this for free, just by running JRuby with Java 6. You can attach to any Java process at all. Remotely too. And get this kind of information. Can your Ruby do that?

torsdag, april 05, 2007

Mongrel in JRuby

As I have told you before, we have been working on getting Mongrel working in JRuby off and on for a long while. One or two months ago, I got the Ragel definition ported correctly and the rest working. The plan is to cooperate with Zed and create a JRuby-native Mongrel gem out there, but until then I will describe the steps you need to take to get this working for yourself.

First of all, you need to install gem_plugin. The easiest way is to use gem:
jem install -y gem_plugin --no-rdoc --no-ri
After this is done, you can either download Mongrel-support from svn://, and build the extension manually, or you can download it directly here: If you decide to build it yourself, you first need a current version of JRuby from trunk. Check out mongrel-support from the Subversion repository and execute these commands:
cp $JRUBY_HOME/lib/jruby.jar lib
ant jar
After that you will have a http11.jar-file in lib. Regardless of how you get the http11.jar-file, place it in $JRUBY_HOME/lib/ruby/site_ruby/1.8/. Then you can proceed in a few different ways. You could copy the Mongrel-files from your MRI installation, or you could download Mongrel from version control. Regardless of how, you need to copy mongrel.rb, mutex_fix.rb and the mongrel-directory from Mongrel into $JRUBY_HOME/lib/ruby/site_ruby/1.8/. You can also copy bin/mongrel_rails into $JRUBY_HOME/bin and change the shebang to point to /usr/bin/env jruby. After this, you are good to go with JRuby and Mongrel.

tisdag, april 03, 2007

On ActiveRecord-JDBC performance

I have been a bit concerned about the performance of our component that connects ActiveRecord with JDBC. Since ActiveRecord demands that every result of a select should be turned into a big array of hashes of strings to strings, I suspected we would be quite inefficient at this, and I wasn't sure I could put all my faith in JDBC either.

So, as a good developer, I decided to test this, with a very small microbenchmark, to see how bad the situation actually was.

Since I really wanted to check the raw database and unmarshalling performance, I decided to not use ActiveRecord classes, but do executions directly. The inner part of my benchmark execution looks like this:
conn.create_table :test_perf, :force => true do |t|
t.column :one, :string
t.column :two, :string

100.times do
conn.insert("INSERT INTO test_perf(one, two) VALUES('one','two')")

1000.times do
conn.select_all("SELECT * FROM test_perf")

conn.drop_table :test_perf

It is executed with a recent MySQL Community Edition 5 server, locally, with matching JDBC drivers. The MRI tests is run with 1.8.6, and both use ActiveRecord 1.15.3. ActiveRecord-JDBC is a prerelease of 0.2.4, available from trunk. My machine is an IBM Thinkpad T43p, running Debian. It's 32bit and Java 6.

The results were highly interesting. First, let's see the baseline: the Ruby results:
      user     system      total        real
7.730000 0.020000 7.750000 ( 8.531013)

Frankly, I wasn't that impressed with these numbers. I thought Ruby database performance was better. Oh well. The interesting part is the JRuby AR-JDBC results:
      user     system      total        real
6.948000 0.000000 6.948000 ( 6.948000)
WOW! We're actually faster in this quite interesting test. Not what I had expected at all, but very welcome news indeed. Note that there is still much block overhead in the interpreter, so the results are a little bit skewed in MRI's favour by this, too.


RedCloth is cool. SuperRedCloth is cooler, faster, nicer, and all in all such a treat. And it works on JRuby now. At the time of writing, I haven't really wired together a gem of it yet, but I hope to get it done soon. Until then, if you want to try this, you can download the necessary jar-file from, install the (very small) SuperRedCloth lib-file into your JRuby, add the superredcloth_scan.jar into your site_ruby for JRuby and everything should be set to go. Be warned, this requires a very recent trunk version of JRuby (something like newer than April 1:st).

SuperRedCloth is another of those nice Ragel based libraries. I'm finding Ragel such a joy to work with; just change the few C-thingies into Java-thingies and everything works exactly the same. Neat.

söndag, april 01, 2007

Some JRuby updates

So, there is prime time for JRuby now. So much, in fact, that I haven't had time to blog properly for a while. And won't have for a few days more. In the meantime, check what we've been busy with: