Skip to content

URI cache for DynamoDB account id based endpoint #6087

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

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

L-Applin
Copy link
Contributor

@L-Applin L-Applin commented May 5, 2025

Motivation and Context

Add caching for account id based endpoint in front of the URI constructors

Modifications

  • Added a SdkURI class which caches calls to the various URI constructors methods.
  • Added customization configuration to codegen to enable usage of SdkURI class in generated endpoint resolution code. Enabled this config only for DynamoDB.

Testing

  • Unit test
  • Performance tests and profiling
  • Canary testing in progress

Types of changes

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

@L-Applin L-Applin marked this pull request as ready for review May 6, 2025 15:24
@L-Applin L-Applin requested a review from a team as a code owner May 6, 2025 15:24
@@ -359,4 +359,8 @@
<Class name="software.amazon.awssdk.v2migration.EnumCasingToV2$Visitor"/>
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
</Match>
<Match>
<Class name="software.amazon.awssdk.utils.uri.SdkUri" />
<Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: where do we cast?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +64 to +65
boolean containsK = cache.containsKey(key);
URI uri = cache.get(key);
Copy link
Contributor

@dagnir dagnir May 8, 2025

Choose a reason for hiding this comment

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

This isn't 100% reliable since the key could have been inserted between 64 and 65. Do we actually need to log this? If we do, should it be done within LruCache instead?

String authority,
String path, String query, String fragment) throws URISyntaxException {
if (!isAccountIdUri(authority)) {
log.trace(() -> "skipping cache for authority" + authority);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: space after authority

*/
private boolean isAccountIdUri(String s) {
int firstCharAfterScheme = 0;
int maxIntSizeBase10 = 10;
Copy link
Contributor

Choose a reason for hiding this comment

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

Make static constant. Also maybe maxIntDigitsBase10

String userInfo, String host, int port,
String path, String query, String fragment) throws URISyntaxException {
if (!isAccountIdUri(host)) {
log.trace(() -> "skipping cache for host" + host);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: space after host

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants