Skip to content

Conversation

@alextwoods
Copy link
Contributor

@alextwoods alextwoods commented Dec 11, 2025

Optimize Endpoint Rule Standard library functions

Motivation and Context

One of the largest costs when resolving endpoints is in calling the various standard library functions. This PR improves performance by optimizing a few of the most common/highest cost functions. See benchmark results below testing section.

Modifications

Testing

All of the rules standard library functions are covered by existing endpoint/codegeneration tests.

Benchmarks

Headline benchmark: All S3 non-error cases:
We see a 1.2x improvement in overall endpoint resolution!

Benchmark                                                                       Mode  Cnt       Score      Error  Units
S3BDDEndpointResolverBenchmark.newStdLib          avgt   20  297459.801 ± 8743.025  ns/op
S3BDDEndpointResolverBenchmark.OldStdLib           avgt   20  365603.611 ± 6100.115  ns/op

Substring: 2.9x faster

Benchmark                            Mode  Cnt     Score     Error  Units
SubStringBenchmark.substring_old     avgt   10  1284.880 ±  36.620  ns/op
SubStringBenchmark.substring_new   avgt   10   433.812 ±  26.816  ns/op

parseArn: 2.7x faster

ParseArnBenchmark.parseArn_old     avgt   10  1008.711 ± 19.934  ns/op
ParseArnBenchmark.parseArn_new  avgt   10   373.102 ± 16.827  ns/op

isValidHostLabel: 10x faster

ValidHostLabelBenchmark.isValidHostLabel_old   avgt 10 1895.023 ± 64.409 ns/op
ValidHostLabelBenchmark.isValidHostLabel_new avgt 10 188.029 ± 33.326 ns/op

isVirtualHostableS3Bucket: 17x faster

Benchmark                                                      Mode  Cnt     Score      Error  Units
VirtualHostableBucketBenchmark.virtualHostable_old               avgt   10  2951.752 ± 1141.777  ns/op
VirtualHostableBucketBenchmark.virtualHostable_new             avgt   10   168.333 ±    4.677  ns/op

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

@alextwoods alextwoods marked this pull request as ready for review December 15, 2025 16:35
@alextwoods alextwoods requested a review from a team as a code owner December 15, 2025 16:35
@sonarqubecloud
Copy link

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.

2 participants