A one second request broken into its parts, where the component that looks like the problem is six per cent of it and the database is seventy-two

Evidence Before Action

Back to Performance Tuning and Capacity Planning · End-to-End Profiling · Resource Utilization Breakdown · Slow Query Identification · Service Offerings

Optimizing what profiling actually shows is slow, not whatever seems like the obvious suspect. This is the least technical item on the list and the one that decides whether the others were worth doing.

1. The Complicated Code Is Rarely the Expensive Code

Intuition points at whatever was hardest to write. That instinct is close to useless, because difficulty and cost are unrelated: the nested loop someone laboured over runs once per request on a small list, while the innocuous helper called from a template runs four hundred times.

The illustration above is the shape this usually takes. The clever algorithm everyone suspects is 60 ms of a one-second request. Halving it saves 30 ms. Deleting it entirely saves six per cent, and that is the ceiling — no amount of work on it can do better. The database, which nobody proposed touching, is 720.

2. The Arithmetic That Sets the Ceiling

Amdahl's law in its practical form: the most any optimisation can gain is the share of total time it occupies. Before changing anything, the only number needed is that share.

Component's share Make it twice as fast Make it instant
5%2.5% faster overall5%
20%10%20%
50%25%50%
80%40%80%

A week spent doubling the speed of something that is five per cent of the request buys 2.5 per cent. The same week spent on the eighty per cent component, for a far more modest improvement, buys several times more. The measurement that tells you which column you are in takes an hour.

3. The Discipline

4. “It Feels Faster”

It usually does, to the person who made the change. They know what to look at, they have a warm cache, and they are predisposed. This is not carelessness; it is how perception works, and it is the reason the step after a change is a measurement rather than an impression.

The same applies in reverse to the original complaint. “The system feels slow” is a real report and a poor specification — it may be one endpoint, one time of day, one customer's data volume, or the network between the user and the server. Turning it into a measurement is the first piece of work, not a preliminary to it. See resource utilization breakdown.

5. What an Unnecessary Fix Costs

Acting without evidence is usually described as wasted effort. The waste is the smaller part.

6. Being Wrong Is the Normal Case

We get this wrong too, and the only defence that works is checking rather than reasoning harder. Three from our own work, all caught by measurement:

None of these were failures of care. They were conclusions drawn one step before the evidence arrived.

How We Approach It

  1. Turn the complaint into a measurement — which endpoint, which percentile, under what load.
  2. Profile before proposing anything, and produce the breakdown of where the time goes.
  3. Compute the ceiling for each candidate change, so effort goes where it can pay.
  4. Change one thing, predict the result, measure it, and record both.
  5. Discard changes that did not help, rather than keeping them because they seemed sensible.
  6. Leave the measurement in place, so the next regression announces itself.

What You Get

The habit this protects is simple and easily lost under pressure: before changing anything, be able to say what fraction of the problem it is.