-
Notifications
You must be signed in to change notification settings - Fork 16
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
Optimize target selection and URI parsing #2398
Conversation
Generate changelog in
|
81330da
to
899e9e6
Compare
TargetUri.Builder builder = TargetUri.builder().uri(uri); | ||
targetUris.addAll(Collections2.transform(resolvedAddresses, addr -> builder.resolvedAddress(addr) | ||
.build())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of the partial-builder-as-factory pattern, since sometimes folks add protections later on to prevent interactions after build()
is called. It shouldn't be an issue here since. the TargetUri type is defined within this repo, so I don't have a terribly strong preference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we add an efficient TargetUri.of(uri, address)
factory method to use instead? That way we bypass the builder entirely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call, updated
.register(stats -> Caffeine.newBuilder() | ||
.maximumWeight(100_000) | ||
.<String, Parsed>weigher((key, _value) -> key.length()) | ||
.expireAfterAccess(Duration.ofMinutes(1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
536c6bf
to
83c3c0d
Compare
I'm not sure why that check is failing on this PR, but I suspect merging this will fix it: #2403 |
#2403 has merged, could you please rebase this to develop when you have a moment? |
83c3c0d
to
668b607
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
Released 4.3.0 |
Parsing String to URI can be expensive in terms of CPU and allocations for high throughput services. This generalizes the caching previously added to DnsSupport in #2398 to also cover ApacheHttpClientBlockingChannel requests and HttpsProxyDefaultRoutePlanner proxy parsing to leverage a shared parsed URI cache.
Parsing String to URI can be expensive in terms of CPU and allocations for high throughput services. This generalizes the caching previously added to DnsSupport in #2398 to also cover ApacheHttpClientBlockingChannel requests and HttpsProxyDefaultRoutePlanner proxy parsing to leverage a shared parsed URI cache.
Parsing String to URI can be expensive in terms of CPU and allocations for high throughput services. This generalizes the caching previously added to DnsSupport in #2398 to also cover ApacheHttpClientBlockingChannel requests and HttpsProxyDefaultRoutePlanner proxy parsing to leverage a shared parsed URI cache.
Before this PR
While reviewing some JFRs from dialogue client heavy service, notice that there are a lot of
byte[]
allocations as a result of parsingString
toURI
. In most cases, these will be be the same input string, so are good candidates for caching.After this PR
==COMMIT_MSG==
Optimize target selection and URI parsing
==COMMIT_MSG==
Possible downsides?
We don't have a great way to inject cache sizing/weight configuration or tagged metrics, so for now have hardcoded max cache weight.