Optimize algorithm performance

Optimize algorithm performance in C++ — with the four heights of help laid out: do it now, make it easier for the next person to accept, work out the right move when you are stuck, and learn the pattern so it stops coming back.

4prompt heights
Open it in the interactive atlas →

The four heights

The same task, four distances: today's deadline, the next reviewer, the stuck moment, the pattern.

Execute — do the immediate task

+
I need this sorting routine to run within our 120ms frame budget on PlayTest servers. Send the…
I need this sorting routine to run within our 120ms frame budget on PlayTest servers. Send the optimized version of the compare-and-swap loop to Mika in engine integration and to me for benching, sign off Friday if latency tests pass. Check for branch mispredictions and inlining opportunities before sending.

Improve — make it easier to accept

+
Before I hand this to Mika in engine integration, make the algorithm easy to review and measure —…
Before I hand this to Mika in engine integration, make the algorithm easy to review and measure — put a simple microbenchmark at the top, show worst-case and average-case times, move the inner compare into a named function so reviewers spot intent, and call out any assumptions about input distribution that would make reviewers hesitate.

Decide — diagnose the stuck moment

+
We ran into a 350ms hitch during level load; the new sort routine ran at that moment. I profiled…

A frame spike just happened during the level load

We ran into a 350ms hitch during level load; the new sort routine ran at that moment. I profiled briefly and saw tails of long comparisons but I don’t know if it’s the comparator, allocation during sorting, or bad pivot choices. I’m worried if I change pivot logic I’ll regress average case. What’s the most likely cause and the safest next change to test in isolation?

Become — change the pattern

+
Across builds we keep losing CPU headroom to ad-hoc sorting routines added for different systems. I…

Latency spikes recur on player-heavy scenes

Across builds we keep losing CPU headroom to ad-hoc sorting routines added for different systems. I waste time rewriting similar micro-optimizations and then unpinned assumptions cause regressions. Which habit should I change so new sorting needs don’t erode frame budget, and what standard checks to add to PRs to prevent future regressions?

Next to this one

Other programming language work people do in C++.

Every task here came from the work, not from a feature list — which is why the prompts name what you want done and never the button that does it. The tool changes; the work does not.
Copyright © LLOS.ai · 2026 — original pedagogy, voice, and design — all rights reserved.

The rest of the map

Same library, five ways in.