Measure where the time goes
What it is
Before optimising, measure each step of a prediction at p50 and p99:
- network into and out of the service;
- feature fetching;
- pre-processing (building the input row);
- the model itself;
- post-processing and logging.
Then optimise the largest step first.
Why it matters
The model is often not the slowest part.
- Feature lookups made one at a time, slow JSON parsing or synchronous logging frequently cost more than the model.
- Speeding up the model by half saves nothing if it was 10% of the time.
In the real world: Profiling Kirana Kart's ETA service shows the model takes 2 ms of a 25 ms request; 15 ms is spent on four separate feature-store calls, which one batched call reduces to 4 ms.
Quantising or distilling a model before profiling. A week of model work saves 3 ms; batching feature reads would have saved 20.