Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add caching to pagegrid #1406

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

michaelkubina
Copy link
Collaborator

@michaelkubina michaelkubina commented Dec 12, 2024

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 corresponding fileGrp 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.

Copy link
Member

@sebastian-meyer sebastian-meyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine, but @beatrycze-volk just introduced a dedicated DocumentCacheManager in #1401. Maybe we should incorporate this into the new cache manager instead of doing our own caching in PageGridController?

@beatrycze-volk
Copy link
Collaborator

Yes, this changes can be added to DocumentCacheManager class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚙ feature A new feature or enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants