RFC: Memoize fetch
This adds a small (3 instances) object cache to memoize XRef::fetch
using PopplerCache
which helps a lot of if we repeatedly parse large Objects, e.g. the document from #673 on the current master
yields before:
poppler-release-build> time ./utils/pdfinfo ~/Downloads/ECFR269_EU_COALITION_EXPLORER_2018_V1.10.pdf
Title: EU Coalition Explorer
Subject: Data of the EU28 Survey on Coalition Building in the European Union
Keywords: EU Coalition Explorer; EU28 Survey; Rethink Europe; ECFR; ECFR Berlin; European Council on Foreign Relations; Josef Janning; Christoph Klavehn; Almut Möller; Wiebke Ewering; Denkbuilder; Dieter Dollacker; Dirk Waldik
Author: ECFR European Council on Foreign Relations
Creator: Adobe Illustrator CS6 (Windows)
Producer: Adobe PDF library 10.01
CreationDate: Mon Oct 29 19:37:25 2018 CET
ModDate: Mon Nov 12 21:39:00 2018 CET
Tagged: no
UserProperties: no
Suspects: no
Form: AcroForm
Syntax Warning: Bad annotation destination
JavaScript: no
Pages: 1113
Encrypted: no
Page size: 1920 x 1166 pts
Page rot: 0
File size: 75609160 bytes
Optimized: no
PDF version: 1.7
real 8m15,392s
user 7m45,789s
sys 0m26,866s
and after this change:
poppler-release-build> time ./utils/pdfinfo ~/Downloads/ECFR269_EU_COALITION_EXPLORER_2018_V1.10.pdf
Title: EU Coalition Explorer
Subject: Data of the EU28 Survey on Coalition Building in the European Union
Keywords: EU Coalition Explorer; EU28 Survey; Rethink Europe; ECFR; ECFR Berlin; European Council on Foreign Relations; Josef Janning; Christoph Klavehn; Almut Möller; Wiebke Ewering; Denkbuilder; Dieter Dollacker; Dirk Waldik
Author: ECFR European Council on Foreign Relations
Creator: Adobe Illustrator CS6 (Windows)
Producer: Adobe PDF library 10.01
CreationDate: Mon Oct 29 19:37:25 2018 CET
ModDate: Mon Nov 12 21:39:00 2018 CET
Tagged: no
UserProperties: no
Suspects: no
Form: AcroForm
Syntax Warning: Bad annotation destination
JavaScript: no
Pages: 1113
Encrypted: no
Page size: 1920 x 1166 pts
Page rot: 0
File size: 75609160 bytes
Optimized: no
PDF version: 1.7
real 0m49,825s
user 0m48,172s
sys 0m1,282s
To do the memoization without side effects, we have to deep copy those objects to avoid modifying shared instances, e.g. objArray
or objDict
instances.
Closes #673