mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-22 00:31:44 +00:00
Stabilises CodSpeed measurements of the LLM-completion benchmarks by removing GC-induced noise from the per-iteration instruction count. CPython's cyclic collector fires on its own clock and, because the multi-turn benchmark only allocates a few KB per iteration, a collection that lands mid-iteration inflates the per-iteration count by tens of percent — exactly the magnitude of the flake that caused #32136's test_completion_multi_turn to be flagged as a -25% regression. The existing ``inline_logging_executor`` fixture already proved the pattern works: deferring asynchronous executor work to a per-iteration inline call removes background-thread scheduling noise. GC is the same class of artefact — non-deterministic, runs orthogonally to the code under test — and gets the same treatment. The deferred collection runs once at session teardown; ``mock_response`` keeps the benchmarks on synthetic allocations so nothing escapes into real tracing. Verified locally: the multi-turn benchmark's standard deviation drops from ~0.37 ms to ~0.001 ms across 20 × 1000-iteration runs, i.e. the GC-attributable variance is now ~370× smaller. |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| conftest.py | ||
| test_a2a_benchmarks.py | ||
| test_benchmarks.py | ||
| test_inference_benchmarks.py | ||
| test_mcp_benchmarks.py | ||