JspWriter's implementation classes usually have a buffer. This buffer can improve performance when you are outputing a lot of small data fragments to the actual IO destination.
But under two conditions, the buffer can do harm to performance.
1)The output data is already in big chunk, merging them into a even bigger buffer is pointless, this will only waste a big temp buffer.
2)The actuall destination is a in-memory IO abstraction, buffering can only cause more data copying.
RuntimePortletUtil.processTemplate() meets both of these conditions. The output data is already in chunk and most of the time it is actually outputing to a UnsynStringWriter.
So we should disable the buffer, but unfortunately, the JspWriter object is created by app-server, and Jsp specification does not provide a way to disable the buffer after creation.
But Jsp specification does define that the buffer size is controled by a protected field in JspWriter. So as long as you are using the standard Jsp specification you can safely turn off the buffer by reflection.
In MessageBoard benchmark test, this fix reduce 2% young gen collections and 2.5% old gen collections.