↓ Skip to main content

Low-Latency From The Ground Up

Most “low-latency” writing is tourism: kernel bypass, colocation, lock-free queues — described by people who’ve never measured the thing they’re optimizing. This series goes the other way.

I have a real trading pipeline — Fortuna’s daily signal engine: it pulls BTC/SOL data, computes z-scores, fits a hidden-Markov regime model, and logs signals to SQLite. It is not a microsecond HFT hot path. That’s the point. The method of low-latency engineering — measure first, find where the time actually goes, optimize the hot path, prove the win by re-measuring — is the same whether your budget is 60 seconds or 60 microseconds. The numbers change; the discipline doesn’t. And that discipline is exactly the measurement muscle SRE and platform work runs on.

So every post here is grounded in code I actually run, with real timings you can reproduce. No faith, no vibes — a perf_counter and a histogram.

  • Post 1 · Measure First — instrument the real pipeline, network-free, and get an honest per-stage latency breakdown. The result overturns what you’d guess: one function is 99.5% of the compute. Everything else is rounding error.
  • Post 2 · Anatomy of a Hot Path — go inside that one function. Why is fitting a Gaussian HMM slow? Ten random restarts × 200 EM iterations × full-covariance matrices — profile it and see where the cycles burn.
  • Post 3 · Shave It — the payoff. Real optimizations with before/after numbers: cut redundant restarts, parallelize across cores, warm-start. Prove each win by re-measuring, or throw it out.
  • Post 4 · Mechanical Sympathy — the cheap wins that aren’t about the algorithm: vectorization, killing needless pandas copies, caching what doesn’t change. Small code, measured impact.
  • Post 5 · When to Reach for C/Rust — the honest ceiling. When does rewriting the hot path in a systems language actually pay, and when is it cargo-culting? Decided by measurement, not résumé-driven development.

The thesis in one line: you cannot optimize what you haven’t measured, and you’d be shocked how often the thing you were about to optimize doesn’t matter.

2026