Closed GoogleCodeExporter closed 9 years ago
I profiled rendering the entire PDF file using a command line tool. The
critical function is CJBig2_GRDProc::decode_Arith_Template0_opt3. It looks like
there is a signficant problem.
control.pdf: 2.6 seconds, 242200 calls
experiment.pdf: 15.25 seconds, 1360848 calls
Original comment by jbrei...@google.com
on 1 Dec 2014 at 9:47
Okay, let's look a little closer. The theory is that we are parsing the symbol
dictionary for every page, despite the fact that many pages share the same
dictionary. I would expect exactly one dictionary parsing for experiment.pdf,
and roughly 11 for control.pdf. Instead, CJBig2_Context::parseSymbolDict() is
called roughly 330 times for both cases.
I think the output of CJBig2_Context::parseSymbolDict() needs to be cached.
Original comment by jbrei...@google.com
on 1 Dec 2014 at 10:07
See line 796 of the source code. Caching the most recent output of
pSymbolDictDecoder->decode_Arith() would make huge difference. Or a little more
cleanly, cache the most recent (or two most recent) contents of
pSegment->m_Result.sd.
https://pdfium.googlesource.com/pdfium/+/master/core/src/fxcodec/jbig2/JBig2_Con
text.cpp
Original comment by jbrei...@google.com
on 3 Dec 2014 at 10:10
The attached patch implements a two element LRU cache for the JBIG2 symbol
dictionary. On my machine it reduces the rendering time of experiment.pdf from
39 seconds to 14 seconds.
Original comment by jbrei...@google.com
on 6 Dec 2014 at 12:01
Attachments:
Thanks @jbreiden. Can you put the patch on https://codereview.chromium.org for
review?
Original comment by bo...@foxitsoftware.com
on 6 Dec 2014 at 1:18
Fixed at
https://pdfium.googlesource.com/pdfium/+/bf42dfea544a8ea3269b139e940f3f8eb38f7a2
7
Original comment by bo...@foxitsoftware.com
on 18 Dec 2014 at 3:18
Original issue reported on code.google.com by
jbrei...@google.com
on 1 Dec 2014 at 6:15Attachments: