Skip to content

Cache auth scheme resolution - #7282

Merged
davidh44 merged 6 commits into
masterfrom
hdavidh/cache-authScheme
Aug 19, 2026
Merged

Cache auth scheme resolution#7282
davidh44 merged 6 commits into
masterfrom
hdavidh/cache-authScheme

Conversation

@davidh44

@davidh44 davidh44 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

Cache deterministic auth scheme resolution results to reduce per-request CPU overhead. Auth scheme resolution is called on every request and produces the same result for a given set of inputs when using the default provider - caching avoids repeated allocation and computation.

Modifications

  • Generate ConcurrentHashMap<String, List<AuthSchemeOption>> authSchemeCache field on sync/async client classes
  • Cache activates only when: 1) no per-request auth scheme provider override AND 2) client-level provider instanceof DefaultXxxAuthSchemeProvider
  • Disabled for endpoint-based auth provider services (e.g. S3) where resolution depends on dynamic endpoint parameters
  • Cache key composition varies by service characteristics:
    • Uniform-auth + sigv4: region
    • Uniform-auth + sigv4a: region + ":" + regionSet
    • Per-op-auth + sigv4: operationName + ":" + region
    • Per-op-auth + sigv4a: operationName + ":" + region + ":" + regionSet

Testing

  • Added unit tests
  • Ran benchmarks confirming no regression on full-roundtrip workloads and significant savings on the isolated auth resolution path

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@davidh44
davidh44 requested a review from a team as a code owner August 14, 2026 23:03
* - Custom client-level providers bypass the cache (instanceof guard)
* - Per-request overrides bypass the cache
* - Default provider with caching doesn't break correctness
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth adding a few more test cases covering:

  • regionSet varies per request
  • different operations get their own results
  • cache hit (default provider resolves only once for repeated same-operation calls)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test cases to cover these

@davidh44 davidh44 changed the title Cache auth scheme resolution results per operation Cache auth scheme resolution Aug 18, 2026
@davidh44
davidh44 enabled auto-merge August 18, 2026 23:14
@davidh44
davidh44 added this pull request to the merge queue Aug 19, 2026
Merged via the queue into master with commit fa30dcd Aug 19, 2026
13 of 14 checks passed
@github-actions

Copy link
Copy Markdown

This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 19, 2026
@davidh44
davidh44 deleted the hdavidh/cache-authScheme branch August 19, 2026 02:02
@alextwoods alextwoods added the perf-improvement Label for PRs that contain performance improvement changes. label Aug 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

perf-improvement Label for PRs that contain performance improvement changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants