Repository navigation
Defer unused aiohttp imports and speed up request body conversion - #4332
Draft
markstuart-oai wants to merge 4 commits into
Draft
markstuart-oai wants to merge 4 commits into
markstuart-oai wants to merge 4 commits into
Conversation
| if not keys.issuperset(snapshot): | ||
| extra = snapshot.keys() - keys | ||
| if any(not _text_row_field(fields[key]) for fields in hints for key in extra if key in fields): | ||
| hints = None |
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.
Changes being requested
With one tool call and 1,024 mixed input items, this patch has been cutting the full run from 436 to 16.6 ms over mock HTTP. For one input message it has been cutting the warm median from 5.18 to 3.89 ms and the time from launch to the first answer from 1,037 to 941 ms with aiohttp installed and HTTPX2 selected.
The sync and async clients have been walking every alternative in a union of typed dictionaries for every message. Switching between text messages, tool calls and tool results has been repeating many of the same field checks and copies.
AiohttpTransport. Import errors from a broken optional installation have been surfacing on first use.Additional context & links
In each run the SDK has been making two Responses requests, executing an async tool between replies and checking the returned history and usage. Mixed histories have been interleaving user and assistant messages with earlier function calls and results. The nested case has also been using lists of content parts every 64 items. Serialized request and response bodies and tool effects have been matching main.
Against the previous draft at
c9fe5ad8, the median has been changing by -86.92% [-87.11, -86.77] with 1,024 mixed items and +0.03% [-0.53, +0.57] with one message. For one message the p95 change against that draft has been spanning zero at +3.17% [-0.20, +10.62]. Its cold intervals have also been spanning zero for all five histories. The one-message cold change against main has been measuring -8.39% [-11.33, -6.40].The benchmark has been rotating main, a second copy of main, the previous draft and this patch through 12 matched process blocks on one CPU. It has been using Agents main at
cecd9ebwith Codex off, Python 3.12.16, Pydantic 2.14.3, HTTPX2 2.14.0 and aiohttp 3.14.5. Cold has been including process launch, imports, setup and the first answer with warm bytecode and file caches. Warm estimates have been using 128 runs after 100 warmups on the two smallest cases and 24 runs after eight warmups on the others. Intervals have been resampling matched blocks. Both clocks have been excluding network and inference time.Validation
Agents SDK regression check
Both clients have been running against Agents SDK main at
cecd9ebwith Codex off. The 95% upper bounds have been staying below a 3% slowdown for 81/83 medians and 30/47 p95 estimates. Both uncertain medians have been coming from SQLite writes. Each workload has been keeping its original sample size and percentile rank. The p95 columns have been showing medians of process estimates. All 95% intervals in this description have been covering individual comparisons.83 median comparisons against client main at f2b2399
Each row has been timing a full batch, request or SDK operation. The original protocol has been using 32 fresh pairs per case, then 64 new pairs for 4 selected rows. Intervals have been resampling whole pairs within the reported cohort. The cold clocks here have been starting after process setup.
cold_normalcold_streamids_17x32769ids_17x32769_streamids_3x8193ids_3x8193_streamreuse_normalreuse_streamtyped_3x257typed_3x257_streamadd_toolbuild_dict_12build_omitted_12build_typed_12con1con32con8diag_32h128handoffs_0handoffs_12history120history2000history720mixed_6nested67_stream16repeat_8retained_16384retained_2048run_dict_6run_omitted_6run_typed_6schemas_24server_1server_1024server_128server_512single_0single_12streamsustained_32time_1024_4096time_16384_2time_2048_2time_2_256time_4096_8tools1tools16tools4warmbatch-compare 1x1024batch-compare 2x32bulk-live 12x64bulk-live 1x1024bulk-live 1x2048bulk-live 1x256combo5 4x1024combo5 8x128concurrent5 2x128first-final 1x0first-mcp 1x0lists-final 1x1024lists-final 8x8192provider-final 1x2048provider-final 1x4096quote-final 1x1quote-final 1x64quote-final 8x16quote-final 8x256quote-final 8x64shape-local normal 12x96shape-local stream 12x96shape-local stream 4x12shape-local stream 8x0tail 4x1024values-final ids 1x1values-final ids 8x8192values-final last 4x512values-final records 8x512values-final typed 16x1024values-final typed 4x128warm-control 1x0warm-control 1x4096Process p95 estimates, including separate confirmations
add_toolbuild_dict_12build_omitted_12build_typed_12con1con32con8diag_32h128handoffs_0handoffs_12history120history2000history720mixed_6repeat_8retained_16384retained_2048run_dict_6run_omitted_6run_typed_6schemas_24server_1single_0single_12streamsustained_32time_16384_2time_2048_2time_4096_8tools1tools16tools4warmbatch-compare 2x32bulk-live 12x64bulk-live 1x256quote-final 1x1quote-final 1x64quote-final 8x16quote-final 8x256quote-final 8x64tail 4x1024values-final ids 1x1warm-control 1x0warm-control 1x4096tail 4x1024In separate runs, the upper bounds for both SQLite writes and all 16 distinct p95 cases with wide intervals have been staying below a 3% slowdown. The 17 original p95 estimates with wide intervals have been including separate 32- and 64-pair runs of the
4×1,024stream. Across 256 fresh pairs per write, the small write has been changing by −0.02% [−1.35%, +1.59%] and the large write by −1.41% [−2.55%, −0.39%].Across 128 fresh pairs per p95 case, the largest upper bound for the patch has been reaching +2.87% (
h128). Two identical copies of main have been giving a wider interval ondiag_32[−0.64%, +3.32%]. Each run has been using the original timing and percentile rules.Separate comparisons with a second copy of main
time_1024_4096time_2_256build_dict_12build_omitted_12build_typed_12con32diag_32h128mixed_6retained_16384run_omitted_6server_1sustained_32warmbatch-compare 2x32quote-final 8x16tail 4x1024warm-control 1x4096