5 exercises on the language of making code faster: profiling, bottlenecks, hot spots, memory leaks, optimising queries, caching, and premature optimization.
Key patterns
profile the code; read the flame graph
identify a bottleneck; find the hot spot
fix / plug a memory leak (steady growth → OOM)
optimise a query; cache a result
avoid premature optimization — measure first
0 / 5 completed
1 / 5
A senior engineer advises a junior: "Don't guess where it's slow — ___ the code first and let the data tell you." Which verb means "measure where time/memory is spent"?
Profile the code — the measurement-first verb:
To profile code is to run it under a profiler that measures where CPU time, memory, or I/O is actually spent, so you optimise based on evidence instead of guesses.
"We profiled the endpoint and 80% of the time was in JSON serialization."
Noun: "the CPU profile shows a hot spot in the parser"
Tools: a profiler; a flame graph visualises the profile
The optimisation workflow:
profile → identify a bottleneck / hot spot → optimise → re-profile / benchmark to confirm the gain
Why not the distractors?Lint = static style/error checking; mock = substitute dependencies in tests; minify = compress assets. None of them measure runtime cost. The golden rule "measure, don't guess" is exactly why the verb is profile.
2 / 5
A profiling write-up says: "The flame graph showed a single ___ — one function burning 60% of CPU." Which term names a concentrated point of high resource consumption?
Hot spot — the profiler's concentrated cost point:
A hot spot is a small region of code that consumes a disproportionate share of CPU, memory, or time — exactly what a profiler is designed to reveal.
"The profiler flagged a hot spot in the regex engine."
"A flame graph makes hot spots obvious — the widest frames."
Related: a bottleneck constrains the whole pipeline; a hot spot is where the cost concentrates.
Blind spot — an area with no monitoring/visibility
Sweet spot — the optimal balance point of a trade-off ("the sweet spot for batch size is ~500")
In performance English, hot = heavily used / expensive; cold = rarely used. The profiler shows the hot spots; you optimise those first.
3 / 5
A bug report reads: "Memory grows steadily until the pod is OOM-killed — looks like a ___." Which term names memory that is allocated but never released?
Memory leak — memory allocated but never freed:
A memory leak is when a program holds on to memory it no longer needs, so usage climbs steadily until the process is killed (often OOM-killed = out-of-memory).
"A retained event listener leaked memory on every request."
Collocations: have / cause / introduce / plug / fix a memory leak; "the heap grows unbounded"; "track the leak with a heap dump"
Related leaks: connection leak, file-descriptor leak, goroutine/thread leak
Distractors are different bugs entirely:
Memory barrier — a low-level instruction enforcing memory-ordering between threads
Buffer overflow — writing beyond a buffer's allocated bounds (a security/corruption bug)
Cache miss — requested data was not in the cache, so it had to be fetched
The tell-tale sign of a leak is steady, monotonic growth ending in an OOM kill — not a sudden crash or corruption.
4 / 5
A database review concludes: "That report page does a full table scan; we should ___ the query by adding an index." Which verb fits making a query faster?
Optimise a query — the standard performance verb (US: optimize):
To optimise a query is to make it run faster or use fewer resources — often by adding an index, rewriting joins, or reducing the rows scanned.
"We optimised the report query and cut it from 4s to 80ms."
Collocations: optimise a query / a hot path / the build / an image; "tune the query", "rewrite the query to avoid an N+1"
Caching is a sibling technique: "we cache the result so we don't recompute it on every request" — but beware cache invalidation
A crucial caveat — premature optimization: Donald Knuth's line, "premature optimization is the root of all evil", warns against optimising before profiling proves it matters. Optimise the measured bottleneck, not your guesses.
Distractors:deprecate = mark for removal; serialize = convert to a transmittable form; obfuscate = deliberately obscure. Only optimise means "make it faster/cheaper".
5 / 5
A reviewer pushes back on a complex change: "This hand-tuned cache is ___ — the endpoint is called twice a day. Keep it simple until profiling says otherwise." Which fixed phrase describes optimising before it's warranted?
Premature optimization — optimising before it pays off:
"Premature optimization" is the well-known anti-pattern of investing effort in performance before profiling has shown it matters — adding complexity that may never earn its keep.
Knuth: "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil."
Collocations: "this is premature optimization", "avoid optimising prematurely", "optimise the measured bottleneck, not a hunch"
The healthy order: make it work → make it right → make it fast (and only when profiling demands it).
Why the distractors are different concepts:
Graceful degradation — keep partial service when something fails or load spikes
Eager evaluation — compute results immediately rather than on demand
Lazy loading — defer loading/computing until the value is actually needed
The phrase warns: profile first, then optimise the real hot spot — not the one you imagine.