Skip to content
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

Avoid re-calculating the xScaleBlockOffset when not necessary in JpegImage._getLinearizedBlockData #11557

Conversation

Snuffleupagus
Copy link
Collaborator

As can be seen in the code, the xScaleBlockOffset typed array doesn't depend on the actual image data but only on the width and x-scale. The width is obviously consistent for an image, and it turns out that in practice the componentScaleX is quite often identical between two (or more) adjacent image components.
All-in-all it's thus not necessary to unconditionally re-compute the xScaleBlockOffset when getting the JPEG image data.

While avoiding, in many cases, one or more loops can never be a bad thing these changes are unfortunately completely dominated by the rest of the JpegImage code and consequently doesn't really show up in benchmark results. Hence I'd understand if this patch is ultimately deemed not necessary.

…pegImage._getLinearizedBlockData`

As can be seen in the code, the `xScaleBlockOffset` typed array doesn't depend on the actual image data but only on the width and x-scale. The width is obviously consistent for an image, and it turns out that in practice the `componentScaleX` is quite often identical between two (or more) adjacent image components.
All-in-all it's thus not necessary to *unconditionally* re-compute the `xScaleBlockOffset` when getting the JPEG image data.

While avoiding, in many cases, one or more loops can never be a bad thing these changes are unfortunately completely dominated by the rest of the JpegImage code and consequently doesn't really show up in benchmark results. *Hence I'd understand if this patch is ultimately deemed not necessary.*
@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Feb 1, 2020

From: Bot.io (Linux m4)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.67.70.0:8877/ab28006e3eeff70/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Feb 1, 2020

From: Bot.io (Windows)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.215.176.217:8877/ae4fa1700398e8d/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Feb 1, 2020

From: Bot.io (Windows)


Failed

Full output at http://54.215.176.217:8877/ae4fa1700398e8d/output.txt

Total script time: 2.21 mins

  • Font tests: FAILED
  • Unit tests: FAILED
  • Regression tests: FAILED

Image differences available at: http://54.215.176.217:8877/ae4fa1700398e8d/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

pdfjsbot commented Feb 1, 2020

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/ab28006e3eeff70/output.txt

Total script time: 19.46 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://54.67.70.0:8877/ab28006e3eeff70/reftest-analyzer.html#web=eq.log

@Snuffleupagus
Copy link
Collaborator Author

This, and the other recent patches for src/core/jpg.js, is an attempt at finding any simple optimization opportunities in the code. If we want to look into using src/core/jpg.js exclusively for all JPEG images, it seems to me that trying to squeeze every bit of "free" performance out of the code cannot hurt :-)

@timvandermeij
Copy link
Contributor

/botio-windows test

@pdfjsbot
Copy link

pdfjsbot commented Feb 8, 2020

From: Bot.io (Windows)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://54.215.176.217:8877/78f7c83a5413be2/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Feb 8, 2020

From: Bot.io (Windows)


Failed

Full output at http://54.215.176.217:8877/78f7c83a5413be2/output.txt

Total script time: 26.23 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://54.215.176.217:8877/78f7c83a5413be2/reftest-analyzer.html#web=eq.log

@timvandermeij timvandermeij merged commit f178805 into mozilla:master Feb 9, 2020
@timvandermeij
Copy link
Contributor

Let's do this. Thanks!

@Snuffleupagus Snuffleupagus deleted the _getLinearizedBlockData-xScaleBlockOffset branch February 9, 2020 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants