## Summary - Move `safe_log_features()` and `update_optimization_cost()` out of blocking `TaskGroup`s into fire-and-forget background tasks across 4 optimization endpoints (optimizer, optimizer_line_profiler, jit_rewrite, adaptive_optimizer) - These DB writes are analytics-only and don't affect response bodies — waiting for them adds 100-300ms per request unnecessarily - Add `aiservice/background.py` with `fire_and_forget()` helper using the same `set` + `add_done_callback` pattern already used in `LLMClient` - `get_or_create_optimization_event()` remains awaited where the response needs `event.id` ## Test plan - [x] All 550 tests pass locally - [ ] Verify response latency improvement in production metrics after deploy - [ ] Confirm `safe_log_features` and `update_optimization_cost` still complete successfully in background (check DB records) --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| aiservice | ||
| .dockerignore | ||