A short guide to profiling

Below are a few jottings, roughly in the order I picked up them. Good background jobs is chiefly a series of little, unglamorous decisions. Nothing here requires a profiler, though it does make things easier.

First steps

Deleting code remains the most satisfying refactor. It is simple to overthink debugging in production. It is harder to just start. Every spring I revisit the same questions about caching. We shipped it behind a flag and watched the graphs for a few days.

A few details

The change showed up slowly, then all at once. Some of this will be self-evident; some of it took me years. Between profiling and refactoring, the second one taught me more.

Most performance problems are really data-shape problems. In September the light changes, and so does the work. Tests are documentation that fails loudly when it goes stale. Most of what I know about database migrations came from getting it wrong first.

Trade-offs

Boring technology is a feature, not a compromise. The particulars matter less than the habit of paying attention. None of this is new, and that is partly why it works. Every summer I revisit the same questions about log files. The fix was three lines; finding it took most of a week.

For a long time I treated feature flags as an afterthought. There is a version of this that is much more complicated. This is not that version. I keep coming back to database migrations, chiefly because it rewards patience. I keep a short list of things to try next; reading other people’s code is near the top.

What I would do differently

For a long time I treated background jobs as an afterthought. Every autumn I revisit the same questions about log files. Half of the work is deciding what to leave out. I like background jobs that shows the marks of how it was made.

  • Compare against last summer
  • Leave room for minimal mistakes
  • Ask someone at a legacy codebase
  • Leave room for incremental mistakes

Most of what I know about caching came from getting it wrong first.

build pipelineserror handlingbackground jobs