mozilla/pdf.js — pull request #3542 by fkaelberer (2013-08-05 10:00:26+00:00)
Title: Faster JBIG2 decoding for Firefox

This PR improves decoding speed of JBIG2 (scanned black & white) images on Firefox, and so improves #2909 and #3448.

Speed was increased via
- inlining two of the most-called functions, and
- converting a sparse array of context objects into a typed array for faster access.

The rendering speed on Firefox 24a2 is increased by factor 1.5x-5x, and by 1.5x in FF25. Chrome28 speed is unaffected.

The timings seem to be a little inconsistent though (maybe because they are measured in a VirtualBox VM?). On Windows, decoding times decreased by factor 1.25 on FF22, and by factor 2 on FF25 nightly.

Can somebody confirm the speedup?

Firefox 24a2:
```
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20130803 Firefox/24.0
-- Grouped By stat, browser, pdf --
stat | browser | pdf | Baseline(ms) | Current(ms) | +/- | % | Result(P<.05)
------------------------------------------------------------------------------------------------
Overall | firefox | issue1810 | 6123 | 2213 | 3910 | 63.86 | faster
Overall | firefox | issue2909 | 20840 | 4297 | 16543 | 79.38 | faster
Overall | firefox | issue3448 | 1811 | 1167 | 643 | 35.54 |
Page Request | firefox | issue1810 | 3 | 3 | 0 | 3.12 |
Page Request | firefox | issue2909 | 42 | 42 | 0 | 0.79 |
Page Request | firefox | issue3448 | 1 | 2 | -0 | -28.57 |
Rendering | firefox | issue1810 | 6120 | 2210 | 3910 | 63.89 | faster
Rendering | firefox | issue2909 | 20797 | 4255 | 16543 | 79.54 | faster
Rendering | firefox | issue3448 | 1809 | 1165 | 644 | 35.59 |
```

Firefox nightly 25a1:
```
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0
-- Grouped By stat, browser, pdf --
stat | browser | pdf | Baseline(ms) | Current(ms) | +/- | % | Result(P<.05)
-----------------------------------------------------------------------------------------------------
Overall | ffNightly | issue1810 | 1944 | 1269 | 676 | 34.74 | faster
Overall | ffNightly | issue2909 | 6738 | 4523 | 2215 | 32.87 | faster
Overall | ffNightly | issue3448 | 681 | 466 | 215 | 31.57 | faster
Page Request | ffNightly | issue1810 | 2 | 3 | -0 | -6.67 |
Page Request | ffNightly | issue2909 | 42 | 42 | -0 | -0.13 |
Page Request | ffNightly | issue3448 | 2 | 2 | -0 | -10.0 |
Rendering | ffNightly | issue1810 | 1941 | 1266 | 676 | 34.8 | faster
Rendering | ffNightly | issue2909 | 6695 | 4480 | 2215 | 33.08 | faster
Rendering | ffNightly | issue3448 | 679 | 464 | 215 | 31.67 | faster
```

Chrome 28:
```
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36
-- Grouped By stat, browser, pdf --
stat | browser | pdf | Baseline(ms) | Current(ms) | +/- | % | Result(P<.05)
----------------------------------------------------------------------------------------------
Overall | chrome28 | issue1810 | 1499 | 1502 | -4 | -0.24 |
Overall | chrome28 | issue2909 | 5313 | 5327 | -13 | -0.25 |
Overall | chrome28 | issue3448 | 501 | 490 | 11 | 2.15 |
Page Request | chrome28 | issue1810 | 3 | 3 | 0 | 0.0 |
Page Request | chrome28 | issue2909 | 47 | 44 | 3 | 6.82 |
Page Request | chrome28 | issue3448 | 4 | 3 | 1 | 33.33 |
Rendering | chrome28 | issue1810 | 1494 | 1497 | -4 | -0.25 |
Rendering | chrome28 | issue2909 | 5260 | 5281 | -20 | -0.39 |
Rendering | chrome28 | issue3448 | 496 | 486 | 10 | 1.98 |
```