Field notes — essays & research notes

Things I've written down.

Ruby, Rails, performance, security and applied machine learning. Updated when something feels finished.

31 posts in Ruby & Rails
RUBY & RAILS 04 / 08 / 26

Migrations that don't take the site down

The dangerous migrations aren't the slow ones. They're the ones that take a lock while old and new code are both running.

3 min
RUBY & RAILS 04 / 01 / 26

One statement instead of ten thousand

Saving records in a loop is the slowest correct way to write data. The alternatives are faster and quietly skip things you may be relying on.

2 min
RUBY & RAILS 03 / 25 / 26

Counting on read is a bug you ship on purpose

A count in a loop is the N+1 nobody spots, because each query is fast and the logs look fine.

2 min
RUBY & RAILS 03 / 11 / 26

Interactive without a single-page app

Turbo gets you most of what a client-side framework does, with the state still on the server where it is easier to reason about.

2 min
RUBY & RAILS 02 / 25 / 26

Feature flags you can build in an afternoon

The value is decoupling deploy from release. That does not require a platform, and the platform is not the hard part.

2 min
RUBY & RAILS 02 / 18 / 26

Ruby pattern matching, in code you'd actually ship

It is not a switch statement. It destructures and validates shape in one expression, which is exactly what parsing external data needs.

2 min
RUBY & RAILS 02 / 04 / 26

The garbage you never had to create

Ruby's collector is fast. The cheapest object is still the one you didn't allocate, and in hot paths that difference is measurable.

2 min
RUBY & RAILS 01 / 28 / 26

Your average response time is lying to you

The mean hides the requests that make people leave. Percentiles, and the arithmetic of how often a user meets your worst case.

2 min
RUBY & RAILS 01 / 14 / 26

Exceptions that tell you what to do

Rescuing broadly turns a specific failure into a mystery. The useful distinction is between what you expected and what you didn't.

2 min