-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Improved HTTP 1.1 ClassRoutingHandler::handle due to un-optimized headers names lookup #25834
Conversation
This is going to add a |
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.
Nice one!
@geoand I'm taking the point on the Julien V comment about "Techempower dev driver model" and I'm trying hard to NOT push optimizations that are worthless outside of what I see in the flamegraphs - I see, as well, that in order to make this more generic, would be nice to have spi methods that's using some public enum of known Http 1.1 and Http 2 header names (with their String-based formatted name) eg // org.jboss.resteasy.reactive.server.spi.ServerHttpRequest
String getRequestHeader(HttpHeader httpHeader);
// :P GC-free: int getAllRequestHeaders(HttpHeader httpHeader, Collection<String> matchingHeaders);
List<String> getAllRequestHeaders(HttpHeader httpHeader); This allows (for http 1.1) to easily (and as quickly as an array look-up) map with the related vert-x cached & optimized http header name constants. If modifying ServerHttpRequest is not an option (nor supporting the enum list of "known" http 1.1/r header names) I don't know how to make this optimization simple and a more elegant then what I've done, but I'm opened to suggestions :) |
We can certainly modify |
Didn't forgotten about it :) Just come back from PTO, will keep on working on this the next weeks ;) |
c4a922a
to
15d9611
Compare
@franz1981 what's the status of this work? |
Thanks for checking @gsmet , Netty has just merged (and Vertx too) some important changes for http and I wish to recheck if these changes makes sense and/or are relevant |
c45bc23
to
e3bb61d
Compare
@geoand Adding more data points and asking for an advice here... Advice first: Line 499 in 5221dac
seems to assume that ServerHttpResponse is a vertxResponse , according to its name.It is correct? I see ServerHttpResponse which can be VertxResteasyReactiveRequestContext , QuarkusResteasyReactiveRequestContext or ServletRequestContext : if it can just be of type QuarkusResteasyReactiveRequestContext maybe worth forcing CONTENT_TYPE to be the vertx HTTP 1.1 HttpHeaders.CONTENT_TYPE AsciiString variant and save checking it on VertxResteasyReactiveRequestContext ?
Than, a more detailed explanation of what the problem we're solving here... Netty, under the hood, try hard to avoid wasteless (and expensive) computations of case-insensitive hash codes for the Http parameters names: for this reason, Netty prefer What happen instead when Currently, for both Techempower's plaintext or whatever HTTP 1.1 request, Quarkus is performing at least 3 lookup which perform such wasteful computations, which are listed here:
Which compute hash codes for known header names ie About the performance impacts:
With such datapoints, feel free to accept/reject the change, although it would just make quarkus a bit more friendly with HTTP and Vertx expected fast-path types. An additional note: why I haven't pushed this 1 year ago? |
It's an incorrect name. At that point, there is no Vert.x dependency.
We would have to include some intelligence if we are going to do this. |
If you think it will make a noticeable difference, I'll have a look at how we can do it |
ok, so re
The one I've already in the changes of this PR should already do it (because are already in the relevant interesting hot spot) |
I am +1 for this change (assuming they have been verified by benchmarks :)) |
Okay, cool |
e3bb61d
to
9a9505f
Compare
I have just discovered that in few cases, checking that the request/response to be of VertX type won't work, because we have few wrapper classes. I will deal with it tomorrow, checking the performance implications and adding some tests too. |
@geoand The last form of this change, while running in my home-lab (Ryzen 7950 using 8 cores from a single NUMA node and other 8 cores for wrk on another NUMA node - kept separated to have stable results), is getting these numbers, for the plaintext test with 128 connections and 16 pipelined requests:
This PR:
Which means ~5.7% better throughput: not a big deal overall. I'll pause this PR till I have the perf lab able to run it, but in the current form the results are not wow, especially since in the real world, the dominant cost will be the http name validation, instead. |
Thanks for the update! |
9a9505f
to
4756828
Compare
Update on this: I've spoken with @galderz this morning about it and it seems that native image isn't that great to optimize But, such cost would likely disappear by using |
Thanks for the update! |
…ders names lookup
4756828
to
948de9f
Compare
I'm closing these being superseded by #37619 |
No description provided.