Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a cache specifically for the pagegrid and optimizes the for-loop.
Background: each call to the PageGrid-Controller requires the whole
structMap PHYSICAL
to be parsed alongside the correspondingfileGrp
for the thumbnail URL. This is a very expensive operation with linear time complexety. Since we always load the whole$entryArray
with each call and pass it later on to the pagination, this results in very long response times as it needs to be processed again and again. The number of pages displayed in the pagegrid (via settings) has no effect on execution time as it only affects the pagination itself.On a manuscript with about 1800 (https://resolver.sub.uni-hamburg.de/kitodo/PPN1842517988) pages the execution time for the pagegrid alone takes about 10+ seconds. After adding the cache it went down to about 50ms (on our development instance) once there was a cached item.
With this PR and the #1405 optimization the whole response time for said document went down from nearly 25 seconds to about 2,5 seconds on our development instance. On a typical book with about 200 pages it went down from about 3,5 seconds to about 600ms.
Sidenote: At the SUB-HH the pagegrid is directly integrated into the details-page as a initially invisible container. once it is opened we present all pages without the pagination with lazy-loading of the thumbnails. This way we always allow for a whole preview of the document and see it as a navigation feature that should not require a page-reload when opened. Typically document have around 200-300 pages, so that we accept edge-cases like these large documents to be still quite slower than others. Even if it the pagegrid is used as a standalone page, this optimization improves performance significantly.