BleakHouse tracking a simple action, using the pure-Ruby memlogger:
ruby physics
ObjectSpace is quantum—you can’t interact with it without changing it. This makes it useless as a profiler. I didn’t realize how useless it was until I wrote BleakHouse, though. Until then, I had guessed that other implementations (such as Rublique) were just poorly done. But even after eliminating leaks in those…
Anyway. The new hotness, BleakHouse 5:

Bonus: it charts memory usage now (swap, real, and combined). And it’s faster.
get hooked
More gems required than before: gruff
, rmagick
, RubyInline
, active_support
.
You need to build a patched Ruby binary, unfortunately. I borrowed Eric Hodel’s patch from mem_inspect
and wrote a Rake task to handle it all for you. To build, just install the plugin one way or another, and then from the bleak_house
folder, run:
sudo rake ruby:build
It will give you a new Ruby 1.8.6 binary called ruby-bleak-house
alongside your existing one.
(Build process tested on OS X. Should be fine on Linux. Won’t work on Windows, but maybe you can hack it out. You should be profiling in an environment that approximates your deployment environment, though, so a win32 version doesn’t really make sense. Unless you deploy on win32. You probably also chew nails for fun.)
using it
The options have changed a bit. Start your server with:
RAILS_ENV=production BLEAK_HOUSE=true ruby-bleak-house script/server
Fire requests. Bonus points if you do it in a repeatable way. Even Monte Carlo methods are more consistent than by-hand. Consider using open-uri
, rfuzz
, httperf
, Selenium, curl
, libcurl
via curb
, etc.
Then:
RAILS_ENV=production SMOOTHNESS=2 rake bleak_house:analyze
The smoothness setting averages series of frames. You can’t set it lower than 2. There’s no upper limit. It’s most useful when you aren’t hitting the same action every request. (It would be nice to use a Gaussian kernel instead of an average, but…)
Check the source if you want to see some interesting things. You can use the memlogger separately, too—you don’t have to profile a Rails app.
And please report problems on the forum.
curtain call
Thanks much to Ryan Davis for RubyInline, Eric Hodel for mem_inspect
, Evan Phoenix for telling me about mem_inspect
, and David Goodlad for helping with the C extension.
Sweet!
So yeah, I wrote Rublique, and this is definitely infinitely superior. At this point there’s little reason to even keep it around. Should I just put a pointer to here on the Rublique page?
A link is probably good idea, especially if you don’t intend to maintain it. I have to thank you for the original version of Rublique, though—the seed in my mind for all of this.
Is it possible to monitor a mongrel/rails process this way—or just webrick/rails?
When I use the supplied starting command, I wind up with a ‘normal’
ruby
process, not aruby-bleak-house
process.I suppose I could symlink my
/usr/local/bin/ruby
to myruby-bleak-house
.There are various ways you can manually start the server, but the symlink is the easiest. The BleakHouse binary is just as reliable as regular Ruby.