<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">Hi Daniel,<div><br></div><div>Here is a PR which fixes it. All tests pass.</div><div><br></div><div><div style="display: block;"><div style="-webkit-user-select: all; -webkit-user-drag: element; display: inline-block;" class="apple-rich-link" draggable="true" role="link" data-url="https://github.com/openjdk/jdk/pull/18667"><a style="border-radius:10px;font-family:-apple-system, Helvetica, Arial, sans-serif;display:block;-webkit-user-select:none;width:300px;user-select:none;-webkit-user-modify:read-only;user-modify:read-only;overflow:hidden;text-decoration:none;" class="lp-rich-link" rel="nofollow" href="https://github.com/openjdk/jdk/pull/18667" dir="ltr" role="button" draggable="false" width="300"><table style="table-layout:fixed;border-collapse:collapse;width:300px;background-color:#E5E6E9;font-family:-apple-system, Helvetica, Arial, sans-serif;" class="lp-rich-link-emailBaseTable" cellpadding="0" cellspacing="0" border="0" width="300"><tbody><tr><td vertical-align="center" align="center"><img style="width:300px;filter:brightness(0.97);height:150px;" width="300" height="150" draggable="false" class="lp-rich-link-mediaImage" alt="18667.png" src="cid:4C5E5EE4-DC20-406E-A6A8-FACECFFAD804"></td></tr><tr><td vertical-align="center"><table bgcolor="#E5E6E9" cellpadding="0" cellspacing="0" width="300" style="font-family:-apple-system, Helvetica, Arial, sans-serif;table-layout:fixed;background-color:rgba(229, 230, 233, 1);" class="lp-rich-link-captionBar"><tbody><tr><td style="padding:8px 0px 8px 0px;" class="lp-rich-link-captionBar-textStackItem"><div style="max-width:100%;margin:0px 16px 0px 16px;overflow:hidden;" class="lp-rich-link-captionBar-textStack"><div style="word-wrap:break-word;font-weight:500;font-size:12px;overflow:hidden;text-overflow:ellipsis;text-align:left;" class="lp-rich-link-captionBar-textStack-topCaption-leading"><a rel="nofollow" href="https://github.com/openjdk/jdk/pull/18667" style="text-decoration: none" draggable="false"><font color="#272727" style="color: rgba(0, 0, 0, 0.847059);">fix for small messages with tcp_nodelay off by robaho · Pull Request #18667 · openjdk/jdk</font></a></div><div style="word-wrap:break-word;font-weight:400;font-size:11px;overflow:hidden;text-overflow:ellipsis;text-align:left;" class="lp-rich-link-captionBar-textStack-bottomCaption-leading"><a rel="nofollow" href="https://github.com/openjdk/jdk/pull/18667" style="text-decoration: none" draggable="false"><font color="#808080" style="color: rgba(0, 0, 0, 0.498039);">github.com</font></a></div></div></td></tr></tbody></table></td></tr></tbody></table></a></div></div><br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Apr 5, 2024, at 5:37 PM, robert engels <rengels@ix.netcom.com> wrote:</div><br class="Apple-interchange-newline"><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">Hi Daniel,<div><br></div><div>I think I have a solution that would work. I will try to get a PR together. Do you know if there is an existing test case the demonstrates the issue? - if not, I will start with that.</div><div><br></div><div>Robert<br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Apr 4, 2024, at 9:44 AM, Daniel Jeliński <djelinski1@gmail.com> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr"><div>Hi Robert,</div><div dir="auto">Thanks for bringing this up! We are aware of the issue, it's tracked under <a href="https://bugs.openjdk.org/browse/JDK-6968351" target="_blank">https://bugs.openjdk.org/browse/JDK-6968351</a>.</div><div dir="auto"><br></div><div dir="auto">If you have an idea for a proper fix that doesn't add too much complexity, please open a PR, and we'll be happy to help.</div><div>Cheers,</div><div>Daniel</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">czw., 4 kwi 2024, 14:55 użytkownik Robert Engels <<a href="mailto:rengels@ix.netcom.com" target="_blank">rengels@ix.netcom.com</a>> napisał:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div dir="ltr"><div dir="ltr">When doing some testing on <a href="http://github.com/robaho/httpserver" rel="noreferrer" target="_blank">github.com/robaho/httpserver</a> - which is a fork of the jdk http server, I discovered a significant performance issue.<div><br></div><div>When an http connection is in ‘keep-alive’ - the default for http 1.1 - the headers are “flushed” here <a href="https://github.com/openjdk/jdk21/blob/890adb6410dab4606a4f26a942aed02fb2f55387/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java#L281" rel="noreferrer" target="_blank">https://github.com/openjdk/jdk21/blob/890adb6410dab4606a4f26a942aed02fb2f55387/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java#L281</a></div><div><br></div><div>This means that after the handler runs and it sends data - e.g. /hello sends “hello” on the connection, the connection will stall due to the Nagel algorithm - usually incurring a 50 ms delay. The stall occurs since the client will not see the expected data until after the delay, so it is unable to send the next (when reusing the same connection/HttpClient).</div><div><br></div><div>You can set the TCP_NODELAY on the server to work-around this, but a better solution would be to override the flush() on the BufferedOutputStream to not flush() the underlying connection - i.e. only write the buffered bytes, or rework it a bit to only flush when there is no content to send.</div><div><br></div></div><div dir="ltr"></div></div></div></blockquote></div>
</div></blockquote></div><br></div></div></div></blockquote></div><br></div></body></html>