jetty / jetty.project

Eclipse Jetty® - Web Container & Clients - supports HTTP/2, HTTP/1.1, HTTP/1.0, websocket, servlets, and more
https://eclipse.dev/jetty
Other
3.85k stars 1.91k forks source link

Jetty 12 - Jetty client library optimizations #8936

Open sbordet opened 1 year ago

sbordet commented 1 year ago

Jetty version(s) 12+

Description Umbrella issue for optimizations to be applied to the client library after #8739.

sbordet commented 1 year ago

Item 1

Currently response listeners are modeled as List<Response.ResponseListener>, but then we always need to extract the content listeners and treat them specially. So perhaps we need to reify the List into a proper class, so that we can use it without having to extract the content listeners all the times. The ResponseNotifier right now does a lot of instanceof which I'm not sure they play well with https://bugs.openjdk.org/browse/JDK-8180450 -- these can be avoided if we have a special class to hold listeners separated.

sbordet commented 1 year ago

Item 2

HttpReceiver.responseXYZ() methods now always create an allocating lambda. To avoid this, we can create a ResponseBeginTask implements Runnable class, so that responseBegin() becomes:

protected void responseBegin(HttpExchange exchange)
{
    responseBeginTask.exchange = exchange;
    invoker.run(responseBeginTask);
}

And similarly for all other events.

sbordet commented 1 year ago

Item 3

HttpReceiver.DecodingContentSource and GzipRequest.GzipTransformer look line-by-line almost identical. Can we factor them out into jetty-http?

lorban commented 1 year ago

For Item 1 we should first check out Red Hat's type pollution agent to figure out how badly we're impacted or not.

sbordet commented 1 year ago

Item 1 is also about getting rid of the "rewrapping" of listeners that happen in HttpRequest, which is a bit weird but required, and may save some allocation.

sbordet commented 1 year ago

Item 1 has been addressed by #9335.

github-actions[bot] commented 8 months ago

This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.

sbordet commented 8 months ago

Item 2 and Item 3 should be addressed.