Using rack-perftools-profiler and proftools.rb with bundler

Background: If you’re not running a Rails/Ruby based web-app with bundler and a non-root user (the most common bundler setup), this article is no help for you.

We’ve all been there. Suddenly, for no apparent reason, your web app is performing like shit, and you don’t know why. All your logging is for naught, and you need to profile your code. And for whatever reason, you have to do it in production.

You google, as we all would. You find rack-perftools_profiller. It sounds awesome, so you try it.

After 4 hours of trying to get bundler to install the damn thing, you give up and light your data center on fire.

TOO BAD YOU DIDN’T READ THIS FIRST.

You have to install the perftools.rb (which the rack-perftools_profiler gem users) gem as a system gem first.

sudo gem install perftools.rb

After this, your deploy and `bundle install` will go fine.

Why, you ask?

Well. You see, when bundler installs a gem that needs a C library compiled, it doesn’t provide the proper ruby env (the env that bundler makes for all the things run in it) to the building process.

That normally doesn’t matter, but in this case, it does. perftools.rb requires some ruby headers that are not installed with the normal “make install”. In order to install them, it usse another gem “ruby_core_source” to fetch and extract them.

Now, ruby_core_source is run from within the C extension building process, which, you’ll recall, doesn’t have the bundler evn setup, and so it doesn’t know where it really should pull the headers to, so it tries to write them to /usr/share/something/something_else. Which fails, and the process bombs.

Now, there’s a patch to ruby_core_source that fixes this. But it’s not released as  a gem you. You may try to circumvent this (as I did) by installed it via bundler, using the :git => “” option. This also fails, as the building process doesn’t get the bundler env, and has no idea  about the installed “good” version.

Installing perftools.rb as root fixes all that, as it lets ruby_core_source install the headers to the system, where perftools.rb can then find them. Even if you have bundler setup to ignore system gems, the header files are already there, so perftools.rb just builds.

I hope I saved you hours of digging.

It’s not me, Android, it’s you.

So, I’ve done it. I’ve ordered a new iPhone 4S. Thus ends my  affair with Android.

What pushed me over the edge, you ask, given my previous “ZOMG I LOVE YOU” posts about Android? Easy.

One day I couldn’t run apps on my phone. Not like, 3rd party apps. Any apps. Reboot? Same. Power off for part of the day? Same. Nothing would run. Phone? No, crash. Messaging? Crash. Market? Crash. ROM Manager to try and maybe update? Crash.

Granted, I’m not running the “factory” firmware, I’m running Cyanogen7. Which is the “gold standard” aftermarket ROM. And yes, it’s the first “real” release for my handset (Samsung Captivate/Galaxy). But it was a real, “go ahead and use this everyday” release. Not beta, not alpha. Real. Release.

So there I was, staring at another round of “re-flash, re-install, re-setup” and I thought…you know what? Enough of this. I’ve been down this road before and it goes no place I want to be.

Like James said to me, when I mentioned I was contemplating switching back because of this, at this stage of my life (professional and personal) I need my tech to just get out of the way and let me work. Re-flashing and all that? That’s not getting out of my way. That’s roadblocking me, and I don’t have time for that.

After my day of “don’t throw the phone through the window” I swapped my SIM card back into my _very_ old 3GS (iOS5 updated though). And it worked. I downloaded some apps. They worked too.  I set up some stuff. Still worked. I’ve been using it for maybe a week now, and you know what? It’s still working. I haven’t had an app crash on me yet. And this 3 year old tech? It works just fine, and has the newest version of iOS. Good luck finding that with Android phones. New version of Android out? Better hope your vendor thinks it’s a good idea to release an update for you, or break out the aftermarket mods. Then good luck getting support from your carrier.

I’m happy to have a phone back that just lets me use it for what I need and doesn’t give me any static, but I’m sad at losing the choice and flexibility that Android offers. Several times over the past week I’ve wished that I could do X with my iPhone, something that’s a no-brainer on Android.

It’s commentary on the state of smart phones that I’m switching back to a less open platform. I don’t know quite what that commentary says, but it feels important to me.  I don’t know many people that have gone from one to the other and back again, and really given both platforms a chance.  I had an iPhone for almost 2 years, and I think I’ve had my Android phone for most of a year. From the blogs I read, that sort of trial is rare, and I’m sad that Android isn’t all that I wanted it to be. It’s close in many respects, but in vendor support and stability it just isn’t there.  I’ve said many times that Android is the Linux of smart phones, with all the baggage that implies, and I have no reason to change my mind.  I used Linux on the desktop for years, and switch back to Macs (ironically) because I needed something that would get out of my way and just let me work.

Android, I’ll miss you, but I’m glad your out of my life for now.  Maybe we’ll meet again when we’re at different stages of our life.

Until then.