Repository navigation
Conversation
test_create_transaction and test_token_bucket_acquire timed out under pytest-benchmark's free-form calibration. Calibration measured the cheapest early calls (an empty MockRuntime store, a full token bucket) and scheduled thousands of rounds, while each later call got slower: the mock store is rewritten in full on every create, and the drained bucket waits for refill. Both hit the 30 s per-test timeout during warmup with no recorded rounds, which then made the JSON report fail with "min() arg is an empty sequence". Use benchmark.pedantic with a per-round setup, as test_state_transition already does: an empty, loaded store for each create, and a fresh primed bucket for each acquire. Each test now runs 100 rounds of the same workload. No SDK code changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The create benchmark only checked the shape of the last returned ID, so a create that returned an ID without saving anything would still pass and record a false speedup. Read every round's transaction back in a pedantic teardown, outside the timed region, and check its id, parties and amount. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comment claimed that priming the bucket kept lock creation out of the timed call. It does not: acquire() can set up its lock on every call, so that cost is part of the measurement. Priming also made no measurable difference (median 8.04 us vs 8.09 us), so drop it and state plainly that each round times one complete non-blocking acquire() on a fresh, full bucket. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Summary
The Performance Benchmarks job fails on
mainwith two timeouts, followed byValueError: min() arg is an empty sequencewhile writing the benchmark JSON.Cause. pytest-benchmark's free-form calibration timed the cheapest early calls and then scheduled far more rounds than fit in the 30 s per-test timeout, because later calls got slower:
TestMockRuntimePerformance::test_create_transaction: the MockRuntime store is rewritten in full on every create, so per-call cost grows with the store (measured locally: about 0.7 ms at 10 transactions, about 57 ms at 2,000). Calibration at 0.49 ms scheduled 2,034 warmup rounds plus 2,034 measured rounds on the growing store.TestRateLimiterPerformance::test_token_bucket_acquire: after the 100-token burst,acquire()waits for refill (8 µs before, 1.1 ms after). Calibration at 7.8 µs scheduled 128,634 rounds and 100,000 warmup rounds.Both tests timed out during warmup with no recorded rounds. The empty stats then broke JSON generation, which produced the
min()error.Fix. Use
benchmark.pedanticwith a per-round setup, the same patterntest_state_transitionalready uses:Each test runs 100 rounds of the same workload. The tests, their assertions, the timeout and all thresholds are unchanged. No SDK source changes.
Verification
Ran locally (Python 3.11) with the workflow's exact command, three times:
test_create_transactionmeantest_token_bucket_acquiremeanNote: the benchmark job runs only on pushes to
main, so this PR's checks will show it as skipped. The local run above is the evidence for the benchmark job.🤖 Generated with Claude Code