Repository navigation
Cache static User-Agent components - #3877
Merged
Merged
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3877 +/- ##
===========================================
- Coverage 92.59% 92.55% -0.05%
===========================================
Files 68 69 +1
Lines 15634 15950 +316
===========================================
+ Hits 14477 14763 +286
- Misses 1157 1187 +30 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
lukasdchang
marked this pull request as ready for review
November 17, 2026 16:21
stobrien89
previously requested changes
Nov 17, 2026
stobrien89
left a comment
Collaborator
There was a problem hiding this comment.
Looks good, just needs a changelog entry
alexgromero
reviewed
Nov 17, 2026
stobrien89
approved these changes
Nov 18, 2026
Alan4506
pushed a commit
that referenced
this pull request
Nov 18, 2026
* release-1.44.6: Bumping version to 1.44.6 Update endpoints model Update to latest models Cache static User-Agent components (#3877)
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
Before this PR, on every API request, the botocore client builds the User-Agent header twice, once per client, on its first request, then again after signing which also gets repeated on every retry. This is a costly operation because it rebuilds every component from scratch and sanitizes each one character by character costing about 21 µs per call.
This PR eliminates repeated work by using a named tuple to store the static parts of a user-agent header once at the beginning of a request. Each build then reuses those cached parts and only adds the request's feature list cutting CPU per call by 13.3% across the benchmark suite with no change to the header that's sent.
Benchmark
Stubbed-HTTP boto3 calls across 71 cases and 5 protocols, on EC2 m7i.xlarge with Python 3.14.8. Each side is the median of 3 interleaved runs.
All 71 cases improved, saving a median of 77 µs per call. The two User-Agent builds in a request dropped from 43.5 µs to 4.8 µs.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.