-
Notifications
You must be signed in to change notification settings - Fork 181
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
Multi-address client: take advantage of lowercase scheme #2975
Conversation
Motivation: In apple#2938 we made it guaranteed that `HttpRequestMetaData#scheme()` result is always in lowercase. We can use that to simplify scheme checks inside `DefaultMultiAddressUrlHttpClientBuilder`. Modifications: - Replace all scheme checks from `equalsIgnoreCase` to `equals`; Result: No need to worry about cases for scheme check.
.../http/http2/src/main/java/io/servicetalk/examples/http/http2/alpn/HttpUrlClientWithAlpn.java
Outdated
Show resolved
Hide resolved
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 strongly opinionated about the examples so feel free to change or ship as-is.
.../http/http2/src/main/java/io/servicetalk/examples/http/http2/alpn/HttpUrlClientWithAlpn.java
Outdated
Show resolved
Hide resolved
// Use HttpRequestMetaData to access "https" constant used by Uri3986 class to optimize "equals" check to be a | ||
// trivial reference check. |
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.
Clever. 😄
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.
The selectClient
was about 10% of CPU on the flame graph. There will be a few more follow-ups in this area, I'm just trying to isolate independent changes in separate PRs
@@ -44,7 +44,7 @@ interface SingleAddressInitializer<U, R> { | |||
/** | |||
* Configures the passed {@link SingleAddressHttpClientBuilder} for the given {@code scheme} and | |||
* {@code address}. | |||
* @param scheme The scheme parsed from the request URI. | |||
* @param scheme The scheme parsed from a {@link HttpRequestMetaData#requestTarget() request URI} in lowercase. |
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.
What about this? Should we freeze this contract in javadoc or also leave us some flexibility?
The javadoc for HttpRequestMetaData#schem()
already says it's always in lowercase.
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.
Decided to keep this PR purely internal. If you feel we need to update javadoc, I will open a follow-up
Motivation:
In #2938 we made it guaranteed that
HttpRequestMetaData#scheme()
result is always in lowercase. We can use that to simplify scheme checks insideDefaultMultiAddressUrlHttpClientBuilder
.Modifications:
equalsIgnoreCase
toequals
;https
string fromUri3986
to speed upequals
check;Result:
No need to worry about cases for scheme check.