Skip to content

Add overloaded menthod for SdkWarmUp.prime overloaded to accept speci…#7130

Merged
joviegas merged 4 commits into
feature/master/crac_auto_priming_supportfrom
joviegas/overload-prime
Jul 13, 2026
Merged

Add overloaded menthod for SdkWarmUp.prime overloaded to accept speci…#7130
joviegas merged 4 commits into
feature/master/crac_auto_priming_supportfrom
joviegas/overload-prime

Conversation

@joviegas

@joviegas joviegas commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

SdkWarmUp.prime() warms every SdkWarmUpProvider on the classpath and the discovered HTTP transports. Applications that use a single client (for example only S3AsyncClient) pay the cost of warming clients and transports they never use. This change adds a targeted overload, SdkWarmUp.prime(Class...), that warms only the requested service clients and only the transports they need.

Modifications

  • SdkWarmUp.prime(Class<? extends SdkClient>...): new @SdkPublicApi overload. Matches each requested class against the registered providers, warms the matched transport through SdkWarmUpProvider.warmUpClient(ClientType), then runs only the HTTP warmer for the matched transports (sync, async, or both). Unmatched classes are logged at warn and skipped. Clients already primed in this JVM are skipped on later calls.
  • TargetedWarmUpInvoker (new, internal): stateless matcher that maps requested class names against each provider's syncClientClassName()/asyncClientClassName() and returns the matched transports so the caller can narrow the HTTP warm-up.
  • PrimedClientRegistry (new, internal): owns the "which clients are already primed" dedup state, so a client is warmed at most once per JVM. State is per-instance (unit-testable with fresh instances); SdkWarmUp holds one long-lived instance.
  • Concurrency: prime(Class...) is lock-free — dedup uses a thread-safe set, and warm-up (network I/O) runs outside any lock. Concurrent calls may briefly double-warm the same client, which is harmless because warming is idempotent. A run that throws before completing does not record the client as primed, so it is retried on the next call. (The PRIME_LOCK mutex is used only by the existing no-arg prime().)

Testing

  • Junits added

Testing

License

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

@joviegas joviegas requested a review from a team as a code owner July 10, 2026 13:47
@joviegas joviegas force-pushed the joviegas/overload-prime branch from 9a05f34 to ccf1b3a Compare July 10, 2026 17:39
boolean warmFailed = false;
Set<ClientType> matched = EnumSet.noneOf(ClientType.class);
for (SdkWarmUpProvider provider : providers) {
ClientType transport = transportFor(requested, provider);

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.

Naming nit - I found "transport" here to be a litlte confusing - this makes me think about http1.1 vs http2 rather than sync vs async. Maybe just use clientType?

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.

Agreed. I renamed transportFor to clientTypeFor, matchedTransports to matchedClientTypes

* successfully.
*/
@SdkInternalApi
public final class TargetedWarmUpResult {

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.

Since this is passed between layers it probably should implement equals/hashcode/toString

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.

Done also added EqualsVerifier test

@joviegas joviegas merged commit 59bf458 into feature/master/crac_auto_priming_support Jul 13, 2026
3 of 4 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 Jul 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants