How Ruby Uses Memory

I’ve never met a developer who complained about code getting faster or taking up less RAM. In Ruby, memory is especially important, yet few developers know the ins-and-outs of why their memory use goes up or down as their code executes. This article will start you off with a basic understanding of how Ruby objects relate to memory use, and we’ll cover a few common tricks to speed up your code while using less memory.

TechShop is Awesome

When we moved into our house on the East Side, the interior walls were all supported by 1 inch thick long leaf pine. A builder looking at the material during a site visit casually mentioned he would make something out of it. This peaked my interests and set me down my recent woodworking path. The only problem was that I didn't have many tools.

Why is RubyGems Slow?

“Why exactly is RubyGems slow?” is the question that more than one developer has asked, but few have bothered to do anything about. Recently @mfazekas took up the task for profiling an especially slow case using dtrace. This resulted in several high profile pull requests to improve performance and drop memory allocations. These in turn lead me to ask the question, just what is Rubygems doing that takes so long? The short answer is, way more than you ever thought; for the long answer, keep reading.

Recruiter Sniping

I first started getting casual emails "we've been looking over your GitHub and we are impressed" and it was validation for me. I enjoyed the attention. It made me feel powerful. I eventually realized that more than a few of those emails came from bots. It was algorithmic, robotic attention. But so what? It still felt good. Occasionally I would get an email from a startup CEO that was personalized beyond a doubt with calls out to specific things I had done. That felt better. Over the years though, these messages went from uplifting, to annoying. These recruiters wanted something from me, they wanted me. But what did I want?

Three Years at Heroku - By the Numbers

This month marks my third year anniversary with Heroku. It's the longest I've worked at a single company and has been the greatest single career move I've made to date.

Nothing Lasts Forever: Symbol Collection in Ruby 2.2

What is symbol GC and why should you care? Ruby 2.2 was just released and in addition to incremental GC, one of the other big features is Symbol GC. If you've been around the Ruby block, you've heard the term "symbol DoS". A symbol denial of service attack occurs when a system creates so many symbols that it runs out of memory. This is because, prior to Ruby 2.2, symbols lived forever. For example in Ruby 2.1:

Debugging Super Methods in Ruby 2.2

Debugging a large codebase is hard. Ruby makes debugging easier by exposing method metadata and caller stack inside Ruby's own process. Recently in Ruby 2.2.0 this meta inspection got another useful feature by exposing super method metadata. In this post we will look at how this information can be used to debug and why it needed to be added.

How (Not) to Troll GitHub Comments

Trolling is horrible and counter-productive; however, we can learn what NOT to do, by asking what a troll would write. Who am I to talk about trolling github comments? I wrote an app, which helps thousands of people get more visibility into open source discussions, so they can make better comments and help out. The service is called CodeTriage and it sends community issues right to your inbox.. Essentially, I read a lot of Github issues and comments. Time to pay the troll toll.

Going the Distance - How Levenshtein Spelling Suggestion Algorithm Works

I'm not what you would cosider an algorithm guy, but after needing to use a bit of spell checking in some code, I became facinated with the Levenshtein distance. I found plenty of resources explaining what it did, I also found plenty of resources with example implementations. What I couldn't find were any really simple explanations for exactly HOW it worked.

Hashie Considered Harmful - An Ode to Hash and OpenStruct

Update: I made a PR to mitigate most of the performance penalty in Omniauth. Deprecating and removing Hashie has resisted several attempts at refactoring. There's also a really good set of discussions in the Reddit comments.

Unraveling String Key Performance in Ruby 2.2

Everyone wants their programs to be faster and to take up less memory. However, it’s not often that this is achieved without having to modify source code. This post will introduce optimizations added in Ruby 2.2.0 when working with a Hash and string keys. To understand the optimization, you need to know current behavior.

36% smaller Rails memory footprint through Benchmarking

America is in the middle of an obesity epidemic, and your Ruby app might be suffering from bloat. While people suffer from overeating, and lack of exercise apps get bigger for other reasons. One of the largest memory sinks in a Ruby app can come not from your code, but from libraries you require. Most developers have no idea what kind of a penalty they incur by adding in a library, and for good reason. Until now, it's been hard to measure.

Benchmarking Rack Middleware

Performance is important, and if we can't measure something, we can't make it fast. Recently, I've had my eye on the ActionDispatch::Static middleware in Rails. This middleware gets put at the front of your stack when you set config.serve_static_assets = true in your Rails app. This middleware has to compare every request that comes in to see if it should render a file from the disk or return the request further up the stack. To do that it hits the disk, basically doing this on every request:

Design Driven Tests: This is how I roll

The only way to be heard in programming these days is to start fires, and kill sacred cows. To which I'll say: Fuck. That. Here's how I write tests, and write design-driven code. I call it T&DD. It's not a prescription, it's how I work.

GEM_PATH

I'm writing this as more of a note to myself than to you. In Ruby GEM_PATH environment variable is where rubygems will look for installed gems. Hidden in in the docs is:

Why We Should (Absolutely Never) Build Software Like We Build Houses

I'm building a house and I write software for a living. So when someone showed me the article Why We Should Build Software Like We Build Houses I had to disagree.

Practice while you Play: Multiple conferences, one Talk

New isn't always better, especially when it comes to conference talks. A number of conferences have a CFP that explicitly looks for "fresh" talks that have never previously been given. My take: practice makes perfect, and repeat talks produces a better experience for attendees

Ditching Tumblr

After 2 weeks of support requests with Tumblr over the inability to see basically any code on my old blog. I'm switching to self hosting!

TIL: Symbol to Proc Trick not needed in Ruby Inject/Reduce 2.0.0

If you’ve been using Ruby for some time no doubt you’ve done something like this to sum up an array of integers: