litellm/tests/benchmarks
izzybn 2c4d234466
fix(guardrails): classify only the frames each read completes in Presidio's first-frame wait (#54379)
* fix(guardrails): classify only the frames each read completes in Presidio's first-frame wait

Presidio's wait for the first frame with a JSON object re-split and re-classified its whole buffer on every read, so a long run of leading non-object frames cost CPU quadratic in the number of reads. It now buffers in a bytearray, finds frame ends only in the newly read bytes, and classifies only the frames that read completed

* test(guardrails): check Presidio's first-frame wait classifies each byte once instead of timing it

The test guide bans checks that depend on execution speed, so the CPU-time limit on the many-leading-reads test is replaced by a test that each read is handed only the frames it completed, including frame ends split across reads

* test(guardrails): drive Presidio's real first-frame wait in its per-read classification test

The test copied the wait's loop, so it still passed if the wait itself dropped the offset the classifier returns. The wait now takes the classifier as a parameter, defaulting to the one it called before, and the test runs the real wait with a recording classifier. The classifier docstring now says the caller relays the preface

* test(benchmarks): benchmark Presidio's first-frame wait over many leading reads and a frame split into many reads

Unit tests can't check the wait's cost without timing it, so CodSpeed now times the real wait over 6000 leading non-object reads and over one 48 KB frame in 16-byte reads. Rescanning every classified frame for a JSON object, or searching the whole unclassified tail for a frame end, makes these runs many times slower

* test(proxy): check the SSE frame-end search directly

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-25 11:15:49 +00:00
..
__init__.py
conftest.py feat(tokenizer): preserve Python defaults with opt-in Rust dispatch (#42174) 2026-09-22 04:41:11 +00:00
test_a2a_benchmarks.py test(benchmarks): add CodSpeed benchmarks for inference, MCP and A2A hot paths (#31716) 2026-06-30 10:27:12 -07:00
test_benchmarks.py refactor: expose core private helpers under public names (#44871) 2026-10-07 00:05:27 +00:00
test_count_tokens_benchmarks.py fix(proxy): count the request's tool_choice on the token count routes (#51133) 2026-11-14 07:53:27 -05:00
test_extraction_guardrail_benchmarks.py feat(extraction): add /v1/extraction with Cloudflare Clairic support (#47473) 2026-10-20 15:51:45 -07:00
test_inference_benchmarks.py test(benchmarks): add CodSpeed benchmarks for inference, MCP and A2A hot paths (#31716) 2026-06-30 10:27:12 -07:00
test_json_fragment_accumulator_benchmarks.py test(json_fragment_accumulator): assert peak allocation instead of a drain timing ratio (#43370) 2026-10-28 22:04:47 -07:00
test_mcp_benchmarks.py refactor(mcp): drop the experimental label from the MCP server and client paths (#48513) 2026-10-27 17:47:50 +00:00
test_presidio_benchmarks.py fix(guardrails): classify only the frames each read completes in Presidio's first-frame wait (#54379) 2026-11-25 11:15:49 +00:00
test_prompt_template_benchmarks.py fix(bedrock): keep shared $defs in Claude tool schemas and bound inlining for other models (#51137) 2026-11-24 04:42:19 -08:00
test_realtime_session_merge_benchmarks.py fix(realtime)!: send the Gemini Live setup at the first content so session.update settings apply (#39864) 2026-10-30 01:31:39 -07:00
test_responses_compaction_benchmarks.py fix(responses)!: round-trip Anthropic compaction blocks as compaction items (#46754) 2026-10-21 08:50:19 +00:00
test_sse_lines_benchmarks.py fix(streaming): keep merged think tags balanced and split SSE lines only on CR/LF (#48755) 2026-10-28 17:00:29 -07:00
test_token_counter_pdf_benchmarks.py fix(token_counter): price PDF pages for OpenAI and Azure models the way they bill (#47554) 2026-10-29 18:24:04 -07:00