Knowledge Guide
HomeSystem DesignMental Models & Systems Thinking

Make It Work → Right → Fast — Profile Before You Optimize

Make it work, make it right, make it fast — in that order

Kent Beck's sequence is a discipline, not a slogan. Correctness first; speed last and only where measured. The opposite — optimizing while building, by intuition — is what Knuth meant by "premature optimization is the root of all evil": you add complexity and bugs to speed up code that wasn't the bottleneck.

A request profile where one DB query is 78% of the time; fixing that beats micro-optimizing the 6% render step; alongside the work-right-fast loop
A request profile where one DB query is 78% of the time; fixing that beats micro-optimizing the 6% render step; alongside the work-right-fast loop

The performance method: measure, don't guess

  1. Establish a baseline & a target — "no number = no goal" (from the approach lesson).
  2. Profile to find the hotspot. Almost always the time is concentrated (Pareto: ~80% in ~20% of the code, often a single function or query). Flame graphs (Brendan Gregg) show it at a glance.
  3. Fix the biggest contributor — and re-measure. The win must show up in the number, not your belief.
  4. Repeat until you hit the target, then stop.

Why fixing the non-bottleneck is wasted — Amdahl's Law: if a part is 6% of runtime, making it infinitely fast saves at most 6%. The diagram's 78% DB query is the only thing worth touching first; add the index, not a faster renderer.

Reading resource health: the USE method

For any resource (CPU, memory, disk, network), check Utilization, Saturation (queueing), and Errors. A saturated, queueing resource is your bottleneck — this is how you find which resource to profile before diving into code.

Pitfalls

Takeaways


Re-authored for this guide; profile/loop diagram hand-authored as SVG. Follows Beck, Knuth, and Brendan Gregg's performance methodology (USE method, flame graphs). See also: How to Approach a Problem, Tail Latency, (Concurrency) Amdahl's Law, How a Query Executes.

🤖 Don't fully get this? Learn it with Claude

Stuck on Make It Work → Right → Fast — Profile Before You Optimize? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **Make It Work → Right → Fast — Profile Before You Optimize** (System Design) and want to truly understand it. Explain Make It Work → Right → Fast — Profile Before You Optimize from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **Make It Work → Right → Fast — Profile Before You Optimize** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **Make It Work → Right → Fast — Profile Before You Optimize** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **Make It Work → Right → Fast — Profile Before You Optimize** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes