[EndpointUri PR 4/4] Optimize EndpointUri creation by pre-parsing urls in codegen#7165
Conversation
…e-parsing Introduce EndpointUrlCodegenAnalyzer which analyzes URL expression trees at code generation time to determine if URL components (scheme, host, port, path) can be statically decomposed. When they can, the codegen emits EndpointUrl.fromComponents(scheme, hostExpr, port, path) instead of EndpointUrl.fromString(fullUrl), eliminating all runtime string parsing. This applies to the vast majority of AWS service endpoints which follow the pattern https://{service}.{region}.{dnsSuffix} — these get zero runtime parsing cost. URLs with dynamic path components (e.g., S3 path-style) fall back to EndpointUrl.fromString() safely. Update CodeGeneratorVisitor.visitEndpointExpression() to invoke the analyzer and select the optimal code path.
|
I think we should really add some conformance testing that compares the runtime resolved endpoint against the build time resolved endpoint. (and also the individual getters like .host(), .port() , etc) This has a huge blast radius and those would give us some more confidence before rolling out this change. Going forward we will be hand maintaining both runtime and buildtime endpoint resolution codepaths that each have their own nuanced (but allegedly equivalent) implementation. If we go to update one of these implementations in the future we might introduce a drift in logic. Conformance testing will help mitigate that risk (and perhaps adding javadoc to make this divergence more visible for future work) |
|
I've added some conformance tests in the However - the real testing that I think protects us is the standard generated endpoint tests for every service's endpoint rules. We require 100% coverage of leaf nodes (eg, Endpoints) and those tests assert that the |
b344ef2
into
feature/master/endpoint-remove-uri
|
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. |
This is PR 4/4 for replacing Uri.create in endpoint resolution with the light weight EndpointUrl.
Note: This PR merges to feature/master/endpoint-remove-uri and NOT to master
Previous PRs:
Modifications
Adds
EndpointUrlCodeEmitterto the rules2 codegen pipeline, which analyzes endpoint URL expression trees at code generation time and emitsEndpointUrl.fromComponents(scheme, host, port, path)instead ofEndpointUrl.fromString(fullUrl)wherever possible. This eliminates runtime string parsing for the vast majority of resolved endpoints.Background: Endpoint URL expressions
Endpoint rules define the Endpoint Object
uriproperty as strings that include template strings.The Java SDK
ExpressionParser.parseStringValue()tokenizes these templates, splitting on{...}boundaries to produce aStringConcatExpression— a list of alternating literals and variable/member-access references:License