[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jetty-dev] NIO inefficiency?
|
Hi Simone,
On Friday, August 9, 2013 at 2:26 PM, Simone Bordet wrote:
Sure, it is writing the bytes (note also that we're talking the 2% of
your CPU time here - any improvement here will probably have little
effect on the total time).
Agreed, this seems quite minor now – when I initially started down on this path it seemed there might be up to 5% potential gain… Nonetheless, might as well squeeze out that extra percent or two while we are at it – I like how Jetty always trims the extra fat ;)
We already try our best to use gather writes and write buffering to
reduce the number of calls to SocketChannel.write().
Sure we can improve in certain spots, but I am not sure what you refer
to with "combine the last flush and the close operations".
Can you expand ?
I believe the scenario here is that the gzip filter does a flush at the end, leading to a NIO write. Then the close at the end of the request forces another NIO write (w/ empty buffer, but the overhead is there). Ideally, this could just be one NIO write. A call to DeflaterOutputStream.finish() would be sufficient to ensure the compressed bytes are written to the buffer, but wouldn't trigger a NIO write (close would take care of that).
Flush from gzip:
org.eclipse.jetty.server.HttpOutput.flush:151
java.util.zip.DeflaterOutputStream.flush:282
org.eclipse.jetty.servlets.gzip.AbstractCompressedStream.flush:125
sun.nio.cs.StreamEncoder.implFlush:297
sun.nio.cs.StreamEncoder.flush:141
java.io.OutputStreamWriter.flush:229
java.io.PrintWriter.flush:320
org.eclipse.jetty.servlets.gzip.CompressedResponseWrapper.finish:343
org.eclipse.jetty.servlets.GzipFilter.doFilter:364
Flush to close:
org.eclipse.jetty.server.HttpOutput.flush:151
org.eclipse.jetty.server.HttpOutput.close:117
org.eclipse.jetty.server.HttpWriter.close:49
java.io.PrintWriter.close:339
org.eclipse.jetty.server.Response.closeOutput:789
org.eclipse.jetty.server.HttpChannel.handle:321