-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(util-endpoint): add endpoint ruleset cache #1385
Merged
Merged
Conversation
This file contains 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
Closed
1 task
kuhe
force-pushed
the
feat/endpoint-cache
branch
2 times, most recently
from
September 3, 2024 18:17
49365a0
to
389ead3
Compare
The S3 resolver would now look like this below. // smithy-typescript generated code
import { awsEndpointFunctions } from "@aws-sdk/util-endpoints";
import { EndpointV2, Logger } from "@smithy/types";
import { customEndpointFunctions, EndpointCache, EndpointParams, resolveEndpoint } from "@smithy/util-endpoints";
import { EndpointParameters } from "./EndpointParameters";
import { ruleSet } from "./ruleset";
const cache = new EndpointCache({
size: 50,
params: [
"Accelerate",
"Bucket",
"DisableAccessPoints",
"DisableMultiRegionAccessPoints",
"DisableS3ExpressSessionAuth",
"Endpoint",
"ForcePathStyle",
"Region",
"UseArnRegion",
"UseDualStack",
"UseFIPS",
"UseGlobalEndpoint",
"UseObjectLambdaEndpoint",
"UseS3ExpressControlEndpoint",
],
});
export const defaultEndpointResolver = (
endpointParams: EndpointParameters,
context: { logger?: Logger } = {}
): EndpointV2 => {
return cache.get(endpointParams as EndpointParams, () =>
resolveEndpoint(ruleSet, {
endpointParams: endpointParams as EndpointParams,
logger: context.logger,
})
);
};
customEndpointFunctions.aws = awsEndpointFunctions; |
In one benchmark, a batch of 10 parallel Amazon S3 HeadObject requests completed in 80ms, as opposed to 86ms without this cache. |
kuhe
force-pushed
the
feat/endpoint-cache
branch
2 times, most recently
from
September 3, 2024 19:52
1f511f3
to
f97331f
Compare
trivikr
approved these changes
Sep 5, 2024
kuhe
force-pushed
the
feat/endpoint-cache
branch
2 times, most recently
from
September 5, 2024 15:52
73e7555
to
4295b21
Compare
milesziemer
reviewed
Sep 5, 2024
...t/java/software/amazon/smithy/typescript/codegen/endpointsV2/RuleSetParameterFinderTest.java
Show resolved
Hide resolved
milesziemer
reviewed
Sep 5, 2024
kuhe
force-pushed
the
feat/endpoint-cache
branch
from
September 5, 2024 20:02
9a72403
to
a33c22a
Compare
milesziemer
approved these changes
Sep 5, 2024
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.
aws/aws-sdk-js-v3#6423
This PR creates a cache for endpoint ruleset resolution.
As one would expect, the input and cache key are the endpoint params and the output and cache value is the endpoint.
Some services declare endpoint parameters in excess of what is actually evaluated in the ruleset, so codegen provides the explicit pared param list to the cache instance.