codeflash-internal/.github
Kevin Turcios 0abc6bf1e3
async: parallelize endpoint epilogue DB writes (#2490)
## Summary

Parallelize independent DB writes at the end of 4 endpoints using
`asyncio.TaskGroup`. With psycopg3 connection pooling (#2489), each task
gets its own connection from the pool.

### Endpoints optimized

| Endpoint | Before | After |
|----------|--------|-------|
| **Refinement** | `log_features` then `update_optimization_cost` |
`TaskGroup` (concurrent) |
| **Explanations** | `update_optimization_cost` inside inner fn | Moved
to handler, `TaskGroup` with `log_features` |
| **Optimization review** | `update_optimization_cost` inside inner fn |
Moved to handler, `TaskGroup` with `update_optimization_features_review`
|
| **Ranker** | `update_optimization_cost` inside inner fn | Moved to
handler, `TaskGroup` with `log_features` |

Each endpoint saves ~87ms (one DB round-trip) by overlapping two
independent writes.

### Comprehensive audit

All 13 endpoints were audited — no remaining async antipatterns found:
- No blocking calls in async paths
- No `await`-in-loop patterns
- LLM clients already use connection reuse
- All other endpoints have at most 1 DB write in the epilogue

## Test plan

- [x] All 538 tests passing
- [ ] Verify under load in staging

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Kevin Turcios <KRRT7@users.noreply.github.com>
Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com>
2026-04-01 06:15:16 -05:00
..
workflows async: parallelize endpoint epilogue DB writes (#2490) 2026-04-01 06:15:16 -05:00
dependabot.yml Make dependabot run monthly rather than weekly 2024-02-12 16:47:21 -08:00
pull_request_template.md VSC package upgrade 0.0.13 (#1931) 2025-10-24 17:39:35 -07:00