-
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
Optimize JPG.js receiveAndExtend for 1 bit case. #4894
Optimize JPG.js receiveAndExtend for 1 bit case. #4894
Conversation
Profiling showed that receiveAndExtend is frequently called with the length of one bit. This happens for example in decodeBaseline. For a single bit, the loop and shift in receive, as well as the shifts in receiveAndExtend are overhead. This shortcut manually calculates the shifts by either returning 1 or -1 from receiveAndExtend by reading the bit and deciding on the return value. While it comes with an overhead for each non-one length, the speedup is at about 10% in the hot parse/decode path.
another improvement in the hot path of our documents. For me it gets about 10%. Disclaimer: I do not know the algorithms involved. I just found it interesting that receiveAndExtends returns -1 when the bit is 0. Initially I thought it should be 0. |
/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/84c7968428e4527/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/d52226fdd54092b/output.txt |
From: Bot.io (Windows)FailedFull output at http://107.22.172.223:8877/d52226fdd54092b/output.txt Total script time: 21.82 mins
Image differences available at: http://107.22.172.223:8877/d52226fdd54092b/reftest-analyzer.html#web=eq.log |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/84c7968428e4527/output.txt Total script time: 26.19 mins
|
This commit speeds up |
/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/76b8f15a540ec51/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/76b8f15a540ec51/output.txt Total script time: 23.48 mins
|
Thank you for the patch |
…xtend Optimize JPG.js receiveAndExtend for 1 bit case.
Profiling showed that receiveAndExtend is frequently called with the length of
one bit. This happens for example in decodeBaseline.
For a single bit, the loop and shift in receive, as well as the shifts in
receiveAndExtend are overhead.
This shortcut manually calculates the shifts by either returning 1 or -1 from
receiveAndExtend by reading the bit and deciding on the return value.
While it comes with an overhead for each non-one length, the speedup is at about
10% in the hot parse/decode path.