-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Less copying in the JPX decoder #4538
Conversation
Sorry, I forgot to lint. Is my use of the switch statement discouraged? |
Just add |
Ok, thanks. |
I started to look at jpx.js too. |
/botio test |
From: Bot.io (Linux)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/b0e205621fc30c5/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.22.172.223:8877/b7d2be751042d18/output.txt |
From: Bot.io (Windows)FailedFull output at http://107.22.172.223:8877/b7d2be751042d18/output.txt Total script time: 2.51 mins
Image differences available at: http://107.22.172.223:8877/b7d2be751042d18/reftest-analyzer.html#web=eq.log |
/botio-windows test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.22.172.223:8877/346b31481483d1a/output.txt |
From: Bot.io (Linux)FailedFull output at http://107.21.233.14:8877/b0e205621fc30c5/output.txt Total script time: 25.63 mins
Image differences available at: http://107.21.233.14:8877/b0e205621fc30c5/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://107.22.172.223:8877/346b31481483d1a/output.txt Total script time: 21.63 mins
Image differences available at: http://107.22.172.223:8877/346b31481483d1a/reftest-analyzer.html#web=eq.log |
/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/c5c61d2a3d64f4d/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/6a5aa1af7e30013/output.txt |
From: Bot.io (Windows)FailedFull output at http://107.22.172.223:8877/6a5aa1af7e30013/output.txt Total script time: 2.51 mins
Image differences available at: http://107.22.172.223:8877/6a5aa1af7e30013/reftest-analyzer.html#web=eq.log |
/botio-windows test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.22.172.223:8877/de08d2879653fe8/output.txt |
From: Bot.io (Linux)FailedFull output at http://107.21.233.14:8877/c5c61d2a3d64f4d/output.txt Total script time: 25.44 mins
Image differences available at: http://107.21.233.14:8877/c5c61d2a3d64f4d/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://107.22.172.223:8877/de08d2879653fe8/output.txt Total script time: 22.25 mins
Image differences available at: http://107.22.172.223:8877/de08d2879653fe8/reftest-analyzer.html#web=eq.log |
Hmm... this patch is supposed to reduce mem consumption. However, I measured a significant increase of > 100MB. Does anybody have an idea why? Difference of the snapshots:
EDIT: the measurement was made with the first page of #2790, which has only one tile (so that the copy process in stream.js is skipped), and uses multi-component transform. |
Let me be more precise on the measurements: This time, I created a fresh profile and I got the following peak RSS using memusg. Each measurement was repeated 5-8 times. In both cases, the new patch delivered much more consistent results.
Environment: Linux Mint Ubuntu-64Bit in a Windows VM. |
Hmmm... I continued to reduce memory allocations, and the peak memory keeps going up. When the jpeg2000 algorithm decodes the image from coarse to fine, it used to first create While the numbers sound good in theory, I wonder why they don't help in practice. Maybe I should try another test file :-]. |
Blocked by #4565. |
Waiting for #4568 to land. |
Good to go! #4568 is in. |
@fkaelberer Could you rebase this PR? |
It is now rebased and merged with p01's changes. I changed the code for shifting and clamping once more from
|
From: Bot.io (Windows)FailedFull output at http://107.22.172.223:8877/4200d9dc57a21f9/output.txt Total script time: 19.89 mins
Image differences available at: http://107.22.172.223:8877/4200d9dc57a21f9/reftest-analyzer.html#web=eq.log |
Any ideas what's wrong? Btw, the memory performance inconsistencies suddenly resolved themselves after a little refactoring. Peak RSS memory is now down from ~355MB to ~333MB using goodytwoshoes00newyiala.pdf, and performance is also better now (Maybe for the same reason as in #3554?). (I could not test with the pdf of #2790 again, because the current Firefox nightly 2014-04-14 crashes when opening that pdf, with or without this patch.) |
Filed an upstream bug, https://bugzilla.mozilla.org/show_bug.cgi?id=996537 |
Since it's a timeout, probably just some intermittent issue. I'll re-trigger the test.
For me, the crash report indicates that this is https://bugzilla.mozilla.org/show_bug.cgi?id=995982. /botio-windows test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.22.172.223:8877/fe6d6e7806b31dc/output.txt |
From: Bot.io (Windows)FailedFull output at http://107.22.172.223:8877/fe6d6e7806b31dc/output.txt Total script time: 19.74 mins
Image differences available at: http://107.22.172.223:8877/fe6d6e7806b31dc/reftest-analyzer.html#web=eq.log |
Hmm, the Firefox tests still time-outs. Unfortunately I have no idea why. |
/botio-windows test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.22.172.223:8877/dcbf24f74d0fa37/output.txt |
From: Bot.io (Windows)FailedFull output at http://107.22.172.223:8877/dcbf24f74d0fa37/output.txt Total script time: 22.93 mins
Image differences available at: http://107.22.172.223:8877/dcbf24f74d0fa37/reftest-analyzer.html#web=eq.log |
This time it was fine, probably intermittent, reviewing... |
@fkaelberer Also needs a rebase again. |
var height = subband.tby1 - subband.tby0; | ||
var codeblocks = subband.codeblocks; | ||
var right = subband.type == 'HL' || subband.type == 'HH' ? 1 : 0; | ||
var bottom = subband.type == 'LH' || subband.type == 'HH' ? levelWidth : 0; |
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.
can we use === here?
Logic looks good. Good to go with rebase and nits above addressed. |
/botio test |
From: Bot.io (Linux)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.21.233.14:8877/8d35cf2a1702c97/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.22.172.223:8877/6be4c9700e4b9f0/output.txt |
From: Bot.io (Windows)FailedFull output at http://107.22.172.223:8877/6be4c9700e4b9f0/output.txt Total script time: 22.33 mins
Image differences available at: http://107.22.172.223:8877/6be4c9700e4b9f0/reftest-analyzer.html#web=eq.log |
From: Bot.io (Linux)FailedFull output at http://107.21.233.14:8877/8d35cf2a1702c97/output.txt Total script time: 25.95 mins
Image differences available at: http://107.21.233.14:8877/8d35cf2a1702c97/reftest-analyzer.html#web=eq.log |
/botio makeref |
From: Bot.io (Windows)ReceivedCommand cmd_makeref from @yurydelendik received. Current queue size: 0 Live output at: http://107.22.172.223:8877/32c9240530c5d54/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_makeref from @yurydelendik received. Current queue size: 0 Live output at: http://107.21.233.14:8877/e2126d58bcd9b07/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/32c9240530c5d54/output.txt Total script time: 23.58 mins
|
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/e2126d58bcd9b07/output.txt Total script time: 25.91 mins
|
Less copying in the JPX decoder
Thank you for the patch. |
The goal of this PR is to reduce the copy operations during JPX decoding.
In the existing code, JPX image are decoded to individual UInt8Arrays for each tile and each color channel in JPX.js, and then joined to a single (rgb) data array in stream.js. This PR now creates a single rgb array for each tile, so merging those in streams.js is simplified, and can be even avoided if only one tile is present (which is the case for example in #2790 and #3181, so it should save time and memory).
I also refactored the shifting and clamping in the JPX code (so this PR supersedes #4531).
Before, there where two loops: one loop for shifting in the unsigned case (L1065), and one loop that shifted in the signed case and clamped to UInt8 (L1080).
I avoided those loops and instead used a shift-and-clamp function when the data is written in the first place.
This patch will not pass the equality test of S2.pdf, because there is a slightly different rounding behavior.
You can make it pass the test by changing line 1024 from
return (value <= -128) ? 0 : ((value >= 127) ? 255 : (value + 128) | 0);
return (value <= -128) ? 0 : ((value >= 127) ? 255 : new Float32Array([value + 128])[0] | 0);
The s2.pdf example contains values that are so close to an integer that truncating to 32 bit precision does make a difference, e.g.
(new Float32Array([119.99999237060547 + 128])[0] | 0) != ((119.99999237060547 + 128) | 0)
.In the old code, the truncation to 32 bit precision happened in line 1075, and so 119.99..+128 was rounded up, whereas now it is rounded down.
When I tried to figure out which of the two possibilities is the correct behavior, I noticed that the jj2000 java reference code produces neither of them: the floating point values differ up to +-4 (in the [-128, 128] range), so if a handful of 119.99-pixels is rounded up or down shouldn't matter here, given that all the other pixels might be off by up to 4. (EDIT: I opened issue #4540 for that).