Optimize HttpReceiverOverHTTP
- Dominant language
- Java
- Stars
- 4.1k
- Forks
- 2k
- Avg merge
- 3d 56m
- Merged PRs (30d)
- 48
Description
**Jetty version(s)**
12.1.x
**Enhancement Description**
`HttpReceiverOverHTTP` has a rather complex, re-entrant, logic that can be improved, likely with impacts to `HttpReceiver` and therefore other transports.
In particular:
* If it is known that there is no content (`Content-Length: 0`, `HEAD` requests, `204 No Content` responses), we should skip allocating the `Content.Source` and notifying `Response.ContentSourceListener`.
This could affect all the transports, and for HTTP/2 and HTTP/3 is even simpler: there is no content of `HeadersFrame.last=true`.
* `HttpReceiverOverHTTP` could optimize the number of syscalls to `read()` and NIO, as currently it performs at least 1 extra syscall to read zero from the network.
This needs to be carefully analyzed, because `responseSuccess()` may trigger the send of a queued request, and an attempt to read in `receiveNext()` may read the response of the queued request that was just sent.
Is it worth to try to read the next response, costing a buffer acquire, network read, and NIO read interest, versus just skipping the read and going directly to NIO read interest?
Contributor guide
Assessment
This issue has not been assessed yet.