HIGHLIGHT — OPTIMISATION
GameParticles
An optimisation contest: take a naïve real-time particle system and make it as fast as possible without changing a pixel. Final capture: 107.68 ms down to 14.71 ms.
Captures — release build, measured
■ before ■ afterRelease build. Contest grading capped at 4.00x — final result nearly doubled the ceiling.
An optimisation contest: everyone gets the same deliberately naïve particle system and the same rule — identical visual output, minimum wall-clock time. The scoring scale maxed out at 4.00x. My final submission ran 7.32x faster than baseline.
The approach
No single trick gets you 7x. The gain came from stacking passes, each verified against the renderer before moving on:
- Precision diet —
doublemath everywhere the original didn’t need it becamefloat, halving bandwidth through the hot loop. - Const-correctness and copy elimination — the baseline copied particle
state through every update; references and
constlet the compiler stop defending against mutation. std::list→std::vector— the particle store went from pointer-chasing to contiguous iteration; the prefetcher does the rest.- Rule of Big Four — explicit copy/assign/move semantics on the hot types so nothing was constructed by accident.
- Object pooling — allocation pulled out of the per-frame path entirely, through a custom pool built on the course’s allocator work.
- Dropping the STL where it cost — after measurement, not on principle.
- SIMD (SSE4.1) — the endgame:
Vect4DandMatrixrewritten on 16-byte-aligned intrinsics, turning four scalar operations into one.
The numbers
| Capture | Frame time | Speedup |
|---|---|---|
| Baseline (naïve) | 107.68 ms | 1.00x |
| Final (all passes) | 14.71 ms | 7.32x |
Every pass was measured in Release against the unchanged rendering output — any visual deviation was a disqualification, so correctness testing was as much of the work as the optimisation itself.
Why it matters
This is the discipline engine teams actually pay for: measure, change one thing, verify, repeat — and know the memory layout story before reaching for intrinsics. The same habits carried directly into the engine and the CUDA work.