#460 — July 25, 2019

Read on the Web

Ruby Weekly

TTY::Logger: Structured, Attractive Logging on the Terminal — Nice looking, colorized and formatted logging.

Piotr Murach

Where Does Rails Spend Its Time? — Noah (who is the subject of our first Ruby Weekly interview - more on that below) profiles Rails Ruby Bench to see where his benchmark is spending most of its time. Unsurprisingly, it involves setting up all those ActiveRecord objects we use.

Noah Gibbs

An In-Depth Look at Ruby's Exception System — 😲 Ruby's exception system is more powerful than many people realize. This book shows you how to get the most from it.

Honeybadger sponsor

Ruby on Whales: Dockerizing Ruby and Rails Development — There a boatload (Ha!) of articles on ‘dockerizing’ Rails apps, but this one is very good and results in a nice setup.

Vladimir Dementyev

Awesome Ruby: A Curated List of Ruby Libraries and Tools — Each year or so, we like to link to this epic, categorized collection of Ruby goodies. It continues to be updated several times a month with new entries added and obsolete entries removed.

Marc Anguera Insa

👋 Be sure to scroll down to the end of this issue to enjoy an interview with Noah Gibbs, a prolific benchmarker of Ruby and Rails, on how he benchmarks Ruby and where he thinks the performance of Ruby 3.x will end up.

💻 Jobs

Fight Poverty by Doing What You Love — We are a Rotterdam based, fast growing crowdfunding platform. Our site is built on a modern stack by a small passionate team.


Find a Job Through Vettery — Vettery matches top tech talent with growing companies. Create a profile to get started.


📘 Articles & Tutorials

Reading Ruby Metaprogramming Inside Devise — Walking through how devise_for adds routes and helpers to your Rails app using that technique you either love or hate: metaprogramming.

Jim Gay

Leaky Constants — A small thing, but did you know if you declare a constant in a block body it becomes a top-level constant?

Filipp Pirozhkov

Learn How to Build Chat with Ruby on Rails and Dialogflow — Learn the inner workings of Stream Chat paired with Ruby on Rails and Dialogflow with this in-depth technical tutorial.

Stream sponsor

▶  Building Chatbots in Ruby with Daniel Pritchett

Ruby Rogues podcast

Demystifying RSpec's DSL with Parentheses? — Just a simple way to wrap your head around RSpec’s often magical seeming API. (I often do this with complex boolean logic as well, just to clarify what’s happening.)

Jason Swett

Spinning Up a 'Rails API'-Powered JSON API in Minutes — A very entry level tutorial, but useful if you haven’t played with Rails’ API-only functionality yet.

Evan Glazer

How to Run Parallel Tests in RSpec on GitLab CI Pipeline

Artur Trzop

Free eBook: How to Get a 3x Performance Improvement on Your Postgres Database

pganalyze sponsor

Fetching Millions of Rows from PostgreSQL in Rails — If you want to do it quickly, you’ll need to lean on raw_connection and send your own query and stream the results from the database.

Gustavo Diel

🛠 Code and Tools

TTY::Box: Draw Frames and Boxes in Your Terminal Window — Staying on a TTY/terminal theme, we’re getting some serious DOS-era UI vibes from this :-)

Piotr Murach

QueryTrack: Find Time-Consuming ActiveRecord Database Queries — Can be used with Slack to provide automated notifications with backtraces, raw SQL, time duration, etc.

Kirill Shevchenko

Audited: An Extension That Logs All Changes to Rails Models — Formerly known as acts_as_audited.

Collective Idea

Valvat: Validates European VAT Numbers — If you’re working on a billing system that involves issuing invoices to European companies, this sort of library is invaluable (we use it ourselves!)

Sebastian Munz

Noah is a Ruby Fellow at AppFolio and has authored countless articles and given many presentations on benchmarking Ruby and Rails. He has also built benchmarking tools, including an official benchmark for Ruby 3x3. We're grateful that he's taken the time to answer a few questions today.

What first inspired you to start benchmarking Ruby so fervently?

When I was chosen for the Ruby Fellow role, I knew I needed to work on performance. That's what they were specifically looking for! I tried a few things including different Ruby compile options, different kinds of profiling... You can see some of that in my early articles. But what worked (for me, for readers, for the Core team) turned out to be the benchmarking. Sometimes you try a few things and find a sweet spot!

What do you see as the largest impact item in Ruby 3x3 when it comes to better performance?

It's hard to narrow Ruby 3x3 performance down - there are so many little fixes! But for non-Rails code, MJIT is huge. For Rails, probably a change to how Ruby handles TraceFunc in Ruby 2.5 that added nearly 10% to the overall speed.

What's the most challenging aspect of your benchmarks?

The most challenging aspect, always, is being sure enough (but never 100%!) that I'm right. Measuring and interpretation are hard, and often I can't be sure what a result means. Re-running tests and extra measurements help, but you're never utterly sure. You've probably noticed that a lot of my conclusions sound nuanced ("X is probably true," "Y seems very unlikely.") That's why!

What's the most worrisome item on the current Ruby roadmap, in your opinion?

I'm not sure I'd call any item on the roadmap "worrisome" - progress is pretty good and we have 18 months left. Static type tools took longer to get really started, but new tools like Sorbet are in surprisingly good shape. We'll get there. I think real-world Rails performance is going to finish at more like double speed than triple. [editor: emphasis is ours] It's at about 172% speed in Ruby 2.6. That should make sense - a lot of Rails time is in the database, or libev or other C extensions and Ruby's speed doesn't affect it. In those cases I'm pretty happy with "only" doubling the end-to-end speed. Especially in a mature 20+-year-old language!

Noah is a Ruby Fellow for AppFolio.