[AAASM-195] ✅ (bench): Add Python-side performance benchmarks for latency contracts#21
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Benchmark the governance interception overhead on each tool/function call when hooks are active (the hot path). Covers all 6 adapters: CrewAI, LangChain, LangGraph, Pydantic AI, OpenAI Agents, MCP. Addresses AAASM-195 AC1: per-call overhead of each framework adapter hook. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace register/unregister cycle measurement with actual per-call patched function overhead for the <2ms P99 contract. Each adapter now benchmarks its real hot path: CrewAI BaseTool.run(), LangChain callback dispatch, LangGraph wrapped node, and async adapters (Pydantic AI, OpenAI Agents, MCP) measured inside event loops. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Document patched-call benchmark results for all 6 adapters. Sync adapters ~1-2us, async adapters ~30-40us (includes event-loop scheduling overhead from benchmark harness). All well under 2ms. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Add a comprehensive Python-side performance benchmark suite to verify the <2ms per-call (AAASM-45) and <50ms detection (AAASM-47) latency contracts. This establishes measurable baselines so future regressions are detectable.
Type of Change
Breaking Changes
Does this PR introduce any breaking changes?
Related Issues
What Changed
pytest-benchmarkto dev dependenciestest/bench/directory with shared fixtures and latency contract constantsbenchmarkpytest marker topytest.iniAdapterRegistry.auto_detect()scaling with 0/1/2/4 frameworksinit_assembly()cold-start timereport_llm_call()PyO3 round-trip (skips when native module not built)time.perf_counter_ns()with P50/P95/P99 percentile reportingtest/bench/BASELINE.md.github/workflows/benchmarks.yml) for automated regression detectionBaseline Results
All benchmarks pass well within contract thresholds:
Testing
Describe the testing performed for this PR:
Run benchmarks:
pytest test/bench/ --benchmark-onlyRun contract tests:
pytest test/bench/test_latency_contracts.py --benchmark-disableChecklist