-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Unnecessary blocking in ResourceService #5937
Comments
Have you changed your response buffer size? At default value, if the content size is less than the buffer size, that sendContent should never block. @gregw Perhaps we should just skip the simpler code path if the response buffer size has been changed from default? |
I agree with the OP that the @charlag would you like to provide a PR? |
@sbordet we just removed the size conditon completely and as you mention "split" it seems like you have something else in mind. |
The Prior to that, the line in question was in the Which was added by commit 0176856#diff-6762e0c2681e4060b6d130dcfb33f458af0ce52a9c033d0fc11036b4fb3c98dbR506 |
My recollection is that small content was not explicitly sent using asynchronous because it was aggregated into the output buffer, which could then asynchronously flushed. Also, small contents are less likely to block and can be entirely flushed within the call to sendContent, so the blocker may never block. However, I'm not so sure that the response buffer size is a reasonable definition of "small content" now. Flip side is that I also don't think it is often worthwhile to startAsync just to send a few bytes of static content. Perhaps the |
For us introduction of many small files resulted in exhausted thread pool (and downtime) with blocking in that place in HttpOutput. I checked and I didn't find us changing buffer size anywhere but I'm not 100% on this to be honest. |
@gregw IIUC this is either past the aggregation, which only happens in I fail to see why there is any logic in there about buffer sizing -- I would just remove the check. |
@gregw with new release of https://mail.tutanota.com (still up) we had around 50 bundles, few kb each. As browsers started detecting the update files started being downloaded by few hundred thousand users at once. I hope this is enough info, feel free to ask for more details. |
Jetty version
9.4.27.v20200227
Java version
14
OS type/version
GNU/Linux
Description
It seems Jetty is doing unnecessary blocking in ResourceService. There's a decision taken based on the content size:
https://github.com/eclipse/jetty.project/blob/b16313b1c89d86f025cbbeccf7aa1a8861788c57/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceService.java#L686-L687
If the data size is smaller than buffer, it is still sent async but with blocking:
https://github.com/eclipse/jetty.project/blob/b16313b1c89d86f025cbbeccf7aa1a8861788c57/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceService.java#L722
https://github.com/eclipse/jetty.project/blob/b16313b1c89d86f025cbbeccf7aa1a8861788c57/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java#L1136-L1143
(line is 1183 for the verison I report but I provide links to the current tree).
We tried to find out justification for doing that but we couldn't. As it's always sent async there's anyway a context switch. It also seems like an attack vector to starve thread pool by requesting small files.
We tried out version which always sends data async, independent of the size and didn't find any issues. As this looks like an oversight to us we would like to report this.
The text was updated successfully, but these errors were encountered: