From c8616f1f358e92a3c3e41f91135bb5d27fa97483 Mon Sep 17 00:00:00 2001 From: poire-z Date: Thu, 16 Feb 2023 23:30:54 +0100 Subject: [PATCH] CreDocument: enable crengine cache with smaller documents --- frontend/document/credocument.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/frontend/document/credocument.lua b/frontend/document/credocument.lua index 9556c09ed..ac9bcf9d4 100644 --- a/frontend/document/credocument.lua +++ b/frontend/document/credocument.lua @@ -233,6 +233,22 @@ function CreDocument:setupDefaultView() self._document:setIntProperty("crengine.image.scaling.zoomout.inline.mode", 0) self._document:setIntProperty("crengine.image.scaling.zoomout.inline.scale", 1) + -- crengine won't create a cache for small documents, which could actually + -- makes re-opening small files slower than big files! + -- Also, we need a cache for ReaderRolling's partial rerenderings handling. + -- In crengine code: + -- A cache is created if the file size is larger than: + -- crengine.cache.filesize.min = PROP_MIN_FILE_SIZE_TO_CACHE: default 300000 + -- (fallback: DOCUMENT_CACHING_SIZE_THRESHOLD=1048576) + -- A cache is searched for (to be used) only if the file size is larger than 65535: + -- hardcoded not overridable: DOCUMENT_CACHING_MIN_SIZE=65535 + -- Other related variables: + -- PROP_FORCED_MIN_FILE_SIZE_TO_CACHE: not used (a hardcoded value of 30000 is used instead) + -- (if filesize < 30000: swapToCache simulated but not really done) + -- DOCUMENT_CACHING_MAX_RAM_USAGE 8388608: not used + -- Force having a cache with small documents (but at least > 65K) + self._document:setIntProperty("crengine.cache.filesize.min", 65536) + -- If switching to two pages on view, we want it to behave like two columns -- and each view to be a single page number (instead of the default of two). -- This ensures that page number and count are consistent between top and