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:

Keep Reading


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.

Keep Reading


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.

Keep Reading


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 fascinated 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.

Keep Reading


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.

Keep Reading


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.

Keep Reading


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.

Keep Reading


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:

Keep Reading


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.

Keep Reading


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:

Keep Reading


Subscribe to my Newsletter 😻 🤠

Join thousands of developers who get new code, writing, and programming links from me delivered to their inboxes.