Home / Would it be possible to speed up SumatraPDF with GPU JPEG2K decompression?
SumatraPDF is pretty slow to read high PPI PDF files, with many pages taking >2 seconds to render, making it a bad experience to read through PDF files with many pages. That’s OpenJPEG’s fault since >90% of CPU time is being used by it.
Apparently gpu_jpeg2k is many times faster than OpenJPEG:
So would it be possible to use gpu_jpeg2k for SumatraPDF? Of course it should be an option/autodetected since it only works with certain graphics cards.
This code requires a recent GPU hardware. Sumatra is conservative in what we require in terms of hardware.
Isn’t it possible to implement it as an option but keep it disabled by default in order to keep the system requirements the same? I’ve seen many programs which have such “hardware acceleration” (including CUDA in this case) off by default. For example LibreOffice can use OpenCL to be faster but it’s disabled by default and available in the options so the requirements don’t require OpenCL. Implementing this would really be a massive improvement, according to the graph on that page it is several times faster than Kakadu and more than 20 times faster than OpenJPEG.
The speedups they’ve measured there are for compression, not decompression. I’m sure there are faster JP2K decoders than OpenJPEG out there, but these are not the benchmarks you’re looking for.
Oh yeah that’s true. Someone should test if gpu_jpeg2k is also faster for decompression then. It very well might be.
Someone should test if gpu_jpeg2k is also faster for decompression then. It very well might be.
Other than the important point brought up by @Dan regarding the graph depicting lossless JPEG2K compression performance, how many PDFs do you see with JPEG2000 images anyway? I for one encounter PDFs with embedded JPGs daily, but have never once come across one with embedded JP2s. So even if this implementation has great JPEG2K decompression speeds, is it backwards compatible with bog-standard JPGs too? If not, given the hardware requirements and extremely low popularity of JP2 compared to JPG, how useful do you think this would be for the vast majority of Sumatra’s users?
In the meantime, five universities have put together funding to sponsor OpenJPEG decoding performance improvements, and those should land later this year.
Interesting news indeed, but unfortunately will make no difference at all unless Sumatra is updated to make use of the improvements in the newer versions of OpenJPEG. See this recent thread for example:
OpenJPEG does JPEG2000 only. And my PDFs keep rendering slowly because of JPEG2000 slowness.
Interesting, I was under the misapprehension that Sumatra was using OpenJPEG for decoding JPGs. So gpu_jpeg2k would simply be a replacement for OpenJPEG for those with the requisite hardware and the need to view JP2s/J2Ks with Sumatra, whereas it wouldn’t matter to those viewing JPGs anyway?
Still, I’m mildly curious about the source of these rather uncommon PDFs with embedded JP2s/J2Ks - where are you obtaining so many of them from?