Optimize performance

Profile, optimize, and verify. Measure first, change one bottleneck at a time, then prove the improvement with tests.

Overview

  • **Goal**: a measurable performance improvement, verified not to break correctness.
  • **Time**: 30–90 minutes.
  • **Skills used**: debug, implement, test.

Prerequisites

  • A measurable symptom (slow endpoint, high memory, long build).
  • A benchmark or repro you can run before and after.

Step 1: Profile to find the bottleneck

Use the debugger to analyze runtime behavior and pinpoint the hot path. Optimization without a profile is guessing.

/vk:eng:debug "<performance symptom>"

Step 2: Implement the optimization

Apply the targeted change identified by the profile. Keep the diff small so the next benchmark is unambiguous.

/vk:eng:implement "<optimization from the profile>"

Step 3: Test and re-measure

Confirm correctness still holds, then re-run your benchmark to verify the win.

/vk:eng:test

Next steps

  • Refactor code Clean up after the optimization.
  • Fix bugs If the optimization introduced a regression.