Rails Builder Is Slow But Easy To Fix

For the impatient: Go install the fast_xs gem if you use Builder in Rails.

The long story:

I was using New Relic RPM to watch Errorlytics, and noticed everything was humming along just fine, except... the Atom feed of new 404 errors was taking an extremely long time. Request times of 800ms were not uncommon. RPM told me that the view rendering was taking most of the time, which made sense because I had already ensured that all the queries were by index.

Errorlytics uses the Atom Builder to construct the Atom feed, and generally I like it. However, I had my doubts after learning it was the bottleneck, and I was hoping I wouldn't have to rip it out and write the XML by hand.

After a bit of Googling around, I was lucky enough to run across Speed up your feed generation in Rails. This post details the same issue, in that the Builder had some major performance issues. Thankfully, the author of that post did all the hard work. They learned that installing the fast_xs gem is the quickest and easiest way to speed up Builder output. Fast_xs implements a common bottleneck as native code, with impressive results.

Bottom line, if you're using Builder in Rails 2.0.2 or later, you should go install fast_xs gem and link it to your Rails application via config.gem 'fast_xs. Your site will thank you.

Popular posts from this blog

Lists and arrays in Dart

Converting Array to List in Scala

Null-aware operators in Dart