-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Estimate the size of decoded streams in advance. #4444
Conversation
@@ -800,6 +808,7 @@ var JpegStream = (function JpegStreamClosure() { | |||
var jpegImage = new JpegImage(); | |||
if (this.colorTransform != -1) | |||
jpegImage.colorTransform = this.colorTransform; | |||
dump('x1\n'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is a leftover from debugging.
When decoding a stream, the decode buffer is often grown multiple times, its byte size increasing like so: 512, 1024, 2048, etc. This patch estimates the minimum size in advance (using the length of the encoded stream), often allowing the smaller sizes to be skipped. It also renames numerous |length| variables as |maybeLength| to make it clear that they can be |null|. I measured this change on eight documents. This change reduces the cumulative size of decode buffer allocations by 0--32%, with 10--20% being typical. This reduces peak RSS by 10 or 20 MiB for several of them.
I removed the stray dump() call. |
/botio test |
From: Bot.io (Linux)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.21.233.14:8877/5bd5b07dfad125b/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.22.172.223:8877/47f982c4bbc8866/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/5bd5b07dfad125b/output.txt Total script time: 26.26 mins
|
From: Bot.io (Windows)FailedFull output at http://107.22.172.223:8877/47f982c4bbc8866/output.txt Total script time: 36.95 mins
Image differences available at: http://107.22.172.223:8877/47f982c4bbc8866/reftest-analyzer.html#web=eq.log |
Estimate the size of decoded streams in advance.
Looks good. Thanks |
When decoding a stream, the decode buffer is often grown multiple times, its
byte size increasing like so: 512, 1024, 2048, etc. This patch estimates the
minimum size in advance (using the length of the encoded stream), often
allowing the smaller sizes to be skipped. It also renames numerous |length|
variables as |maybeLength| to make it clear that they can be |null|.
I measured this change on eight documents. This change reduces the cumulative
size of decode buffer allocations by 0--32%, with 10--20% being typical. This
reduces peak RSS by 10 or 20 MiB for several of them.
BTW, I think Ascii85 and AsciiHex streams are the only ones for which the decoded data is regularly smaller than the encoded data, and I've accounted for that. Please let me know if any of the other stream kinds have the same behaviour.