Bug 56521 - Reuse the output buffer in AbstractServletOutputStream
Summary: Reuse the output buffer in AbstractServletOutputStream
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Servlet & JSP API (show other bugs)
Version: 7.0.47
Hardware: PC Linux
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2014-05-14 07:35 UTC by leonzhx
Modified: 2014-05-20 19:03 UTC (History)
0 users

diff file of (2.64 KB, patch)
2014-05-14 07:35 UTC, leonzhx
Details | Diff
AB testing result for performance (40.92 KB, image/png)
2014-05-14 08:09 UTC, leonzhx

Note You need to log in before you can comment on or make changes to this bug.
Description leonzhx 2014-05-14 07:35:37 UTC
Created attachment 31618 [details]
diff file of
Comment 1 leonzhx 2014-05-14 07:48:17 UTC
in AbstractServletOutputStream, there is an output buffer to save the unwritten bytes for one write in non-blocking mode. However the buffer is allocate each time it's needed and will cause many unnecessary trash. We observed it during our performance testing when the server runs for long time at high TPS, the GC over head is getting larger. After improvement the GC overhead is lowered and CPU usage is also lowered with same TPS.
Comment 2 leonzhx 2014-05-14 07:51:01 UTC
it's in package org.apache.coyote.http11.upgrade
Comment 3 leonzhx 2014-05-14 08:05:51 UTC
Here TPS is Transaction Per Second which indicates the throughput of the server.
Comment 4 leonzhx 2014-05-14 08:09:24 UTC
Created attachment 31619 [details]
AB testing result for performance

the red line is the performance of the patched server while the green one is the base.
Comment 5 Mark Thomas 2014-05-19 19:54:52 UTC
The other thing that would significantly reduce garbage is not to copy the data from the buffer to a new buffer if it is not fully written.
Comment 6 Mark Thomas 2014-05-20 19:03:10 UTC
Fixed in 8.0.x for 8.0.9 onwards and in 7.0.x fir 7.0.55 onwards.