Red Green Performance Testing with The Grinder

No, not that Red Green!

Even a thoroughly-tested application can wreck havoc if it hasn’t been tested in the context of a production-like system under production-like conditions.

Tools like Puppet and Chef make it easy to produce a production-like environment for testing, but what about the production-like conditions?

One aspect of these conditions can be approximated with load testing tools like JMeter or The Grinder. I recently used The Grinder to troubleshoot a performance problem with a small web application. Here’s a walkthrough of my process. Read more on Red Green Performance Testing with The Grinder…

ActiveRecord Join Models Hash Themselves into Bad Performance

ActiveRecord’s implementation of #hash is lacking, if not outright broken. I came across this issue while fixing an N + 1 problem in my current Rails application. I’ll use the proverbial Author/Book example to explain. I was doing something like:

@authors = Author.where(some_cond: true)

Later on in my code, I was looping over each author’s books (classic N+1). To fix, just sprinkle on some includes:

@authors = Author.where(some_cond: true).includes(:books)

There, fixed it. Page now loads in… 2 minutes!. How did that happen?

Read more on ActiveRecord Join Models Hash Themselves into Bad Performance…

Is Your Application Running with Ruby – Slow?

The problem that this post describes has now been fixed in RVM stable (1.17.0). To diagnose performance issues, be sure to check the options that Ruby was compiled with:
ruby -rrbconfig -e 'puts RbConfig::CONFIG["CFLAGS"]'

The Situation

While working with Patrick Bacon, migrating a large Ruby (ruby-1.9.2) web application from an older Solaris system to a new Linux system (Ubuntu 12.04 LTS), we discovered that the migrated web application seemed to be responding rather sluggishly. Comparing the logs, we found that the application was running, generally, about twice as slow on the new system as on the old system.

My first thought was hardware — the new system must be slower. Both systems were cloud servers, but hosted with different companies. Even though the Linux system was hosted on a much newer cloud platform, there was no guarantee that the underlying hardware was new or fast. But, at the same time, I just could not believe that the new system would be twice as slow.

Read more on Is Your Application Running with Ruby – Slow?…

Generic Memoization in C#

I have seen some very nice, generic forms of memoization in the dynamic languages I’ve used. In languages like Ruby and Perl, for example, dynamically redefining a method to be a memoized version of itself is a good way to transparently handle it. However, I haven’t seen any examples of generic case memoization for C# methods that I’ve been happy with. So I took a stab at it.

Read more on Generic Memoization in C#…