Optimizations
Performance, memory, or allocation improvements with no behavioural change. Numbered O1, O2, ... and never part of phase numbering.
Gate requirements for every optimization:
- All existing tests pass with identical output to the pre-change baseline.
- No test assertions were relaxed.
- The relevant benchmark shows measurable improvement.
Pending
O5: Chunked Simulation Runner
SimulationRunner pre-generates all normals and keeps all paths in
memory simultaneously. For large simulations (100k+ paths) this exceeds
1 GB working set.
-
Add
chunk_size: usizetoSimulationConfig(default 0 = all at once). - Split paths into chunks; generate normals per chunk.
-
Deterministic RNG: chunk
kusesseed + path_offset + 1. - Memory benchmark: 100k paths x 1000 steps, chunk_size=0 vs 1000.
Target: Peak memory reduced by >= 5x with chunk_size=1000.
Completed
O7: Cache the LQ Riccati solution — 2026-08-29
Cached the backward Riccati trajectory (P(t), q(t), and R^-1) in an
OnceLock so each time level is integrated once instead of once per grid node
per time step. lq_correlated_fd.rs dropped from 15.11 s to 0.32 s in the
debug profile (~47x) and 1.27 s to 0.03 s in release (~42x). Riccati values
bit-identical to the post-fix baseline.
O6: Generalize Solver Output Layer — 2026-08-02
Replaced NumericalResult<N> with GridSolution<N> (generic) and
SpreadResult (MM-specific). Solver::solve returns GridSolution<N>,
solve_with_spreads returns SpreadResult. Updated 20+ call sites.
Zero behavioural change.
O4: Process Micro-optimizations — 2026-08-02
Precomputed fields in GBM, Heston, RoughOU. GBM -12.1%, Heston -19.1%, RoughOU -12.5%. Zero behavioural change.
O3: Solver FD Throughput — 2026-08-02
Auto-route N=2 Implicit/CN to Strang ADI. 2D 101x100 500 steps: 87.9 ms (~1.5x). Zero behavioural change.
O2: Hawkes Intensity O(1) Recurrence — 2026-08-02
Recursive intensity update, periodic prune. 500x1000: 36.0 ms. <3% relative error in mean intensity. Zero behavioural change.
O1: Engine Allocation Hot Path — 2026-08-02
Stack arrays, capacity pre-allocation, rayon parallel VecEnv. 904 steps/sec for N=1024 (target >=500). Zero behavioural change.