[MGNLCACHE-35] Delegating ServletOutputStream implementations should delegate calls for writing chunks Created: 25/Nov/13  Updated: 14/Feb/14  Resolved: 25/Nov/13

Status: Closed
Project: Cache Modules
Component/s: None
Affects Version/s: None
Fix Version/s: 5.2.1

Type: Improvement Priority: Neutral
Reporter: Tobias Mattsson Assignee: Tobias Mattsson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Cloners
is cloned by MAGNOLIA-5680 Backport MGNLCACHE-35 Delegating Serv... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:

 Description   

Currently GZipCacheResponseWrapper.DeferredServletOutputStream and SimpleServletOutputStream only overrides write(byte) and therefore each byte is treated individually when written to the output stream.

This happens when we're caching, for instance serving pages via RenderingEngine, images from the imaging module and the dam module.

We also go through this code when the gzip filter wraps the response in order to compress it.

By implementing write(byte[]) and write(byte[], int, int) we can reduce the amount of work needed both in these classes and the classes being delegated to. Specifically ThresholdingOutputStream can test if the threshold will be exceeded once instead of for every byte.

The improvements in performance by this fix has been measured to be very limited.



 Comments   
Comment by Michiel Meeuwissen [ 11/Feb/14 ]

Could this be backported to the 4.5 branch? I don't think the improvements in performance are 'very limited'. It will probably decrease the time to serve a large image from 30 seconds to a 100 milliseconds or so.

Comment by Tobias Mattsson [ 14/Feb/14 ]

My measurements showed that it was barely noticeable, less than a 1% improvement. We can still backport it though, being done as MAGNOLIA-5680.

Comment by Michiel Meeuwissen [ 14/Feb/14 ]

I think the point was that for big images the image will first be written to the filesystem and this remains to be wrapped in SimpleServletOutputStream. I suppose mainly writing to filesystem in this way works quite slow. I wouldn't be surprised that it matter much less otherwise.

Comment by Michiel Meeuwissen [ 14/Feb/14 ]

Thanks!

Generated at Sun Feb 11 23:51:34 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.