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 06 / 30 / 26

The 55% page-load win was four queries and a cache key

Cutting clinical-study page loads by more than half under real traffic. Not a rewrite — profiling, eager loading, and one honest look at what was cacheable.

4 min
RUBY & RAILS 06 / 24 / 26

Everything that runs before your controller

A Rails request passes through twenty-odd middleware before your code sees it. Knowing the stack turns a class of mystery into a list.

2 min
RUBY & RAILS 06 / 10 / 26

Time zones: store UTC, and know which "now" you called

Most time-zone bugs come from two nearly identical methods and one place where dates are not really times.

2 min
RUBY & RAILS 05 / 27 / 26

The tests worth writing

Coverage measures which lines ran, not whether anything is verified. What actually catches regressions is narrower and cheaper than a coverage target.

2 min
RUBY & RAILS 05 / 19 / 26

YJIT is free performance, until you read the memory graph

15–30% faster for a flag you probably already have on. What it costs per worker, and the one case where you should turn it down rather than off.

4 min
RUBY & RAILS 05 / 13 / 26

Processing a million rows without loading a million rows

`map` builds an array. On a large collection that array is the problem, and the fix is usually one method name.

3 min
RUBY & RAILS 05 / 01 / 26

Stop guessing: profiling Ruby properly

Benchmarking a suspicion confirms the suspicion. A sampling profiler tells you where the time actually went.

3 min
RUBY & RAILS 04 / 28 / 26

Retries fell 30% when I stopped retrying the wrong things

A retry is a bet that the failure was temporary. Most retried jobs were losing that bet — and the ones that won were doing their work twice.

5 min
RUBY & RAILS 04 / 22 / 26

Reading a query plan without fear

EXPLAIN output looks impenetrable and answers three questions. Those three cover most of what makes a query slow.

3 min