Repository navigation
perf(auth): avoid per-byte URI formatting - #172
Merged
Merged
Conversation
Greptile SummaryThe PR optimizes SigV4 canonical-query construction by sharing one implementation between signing and validation and writing percent escapes directly into a preallocated buffer.
Confidence Score: 5/5The PR appears safe to merge with no actionable correctness, security, or compatibility regressions identified. The shared implementation preserves the previous byte-wise SigV4 encoding and sorting behavior across both request validation and upstream re-signing while removing intermediate allocations. Important Files Changed
Reviews (1): Last reviewed commit: "perf(auth): avoid per-byte URI formattin..." | Re-trigger Greptile |
|
🎉 This PR is included in version 1.18.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Build canonical query pairs in one buffer and write percent escapes directly with uppercase hexadecimal digits instead of formatting an intermediate string for each escaped byte.
The buffer reserves for worst-case escaping rather than adding a byte-counting prepass. SigV4 sorting, unreserved-byte handling, and
encodeSlashbehavior remain unchanged. The focused benchmarks cover reserved query keys and values through the signing passthrough path.Testing
make lint-cimake test-authmake test-proxyWorkload:
reserved-byte canonical query validationns/opB/opallocs/opWorkload:
signed passthrough with reserved query keys and valuesns/opB/opallocs/opGenerated by Perfloop. Measurements and checks.
Note
Low Risk
Performance-only refactor on the signing/validation hot path with parity tests and benchmarks; SigV4 sorting and encoding rules are intended to be unchanged.
Overview
Canonical query string building is refactored for fewer allocations: signer and validator now share
canonicalQueryString, which writes sortedkey=valuepairs into one pre-sizedstrings.Builderinstead of building intermediate strings per pair.SigV4 percent-encoding adds
writeAWSURIEncodedsoawsURIEncodeand canonical queries write%XXescapes via a hex lookup table rather thanfmt.Sprintfper byte.Tests and benchmarks add shared fixtures for reserved query keys/values (slashes, spaces,
+, Unicode) across signer and validator, plus auth and proxy passthrough benchmarks on heavily escaped queries.Reviewed by Cursor Bugbot for commit f45288e. Bugbot is set up for automated code reviews on this repo. Configure here.