Skip to content

Fix slow library loading and repeated blocked-thread warnings - #604

Open
PaoloElMarinelo wants to merge 1 commit into
marian-m12l:masterfrom
PaoloElMarinelo:fix/library-loading-performance
Open

Fix slow library loading and repeated blocked-thread warnings#604
PaoloElMarinelo wants to merge 1 commit into
marian-m12l:masterfrom
PaoloElMarinelo:fix/library-loading-performance

Conversation

@PaoloElMarinelo

Copy link
Copy Markdown

Summary

The local library screen could take minutes to load and spam the console with io.vertx.core.VertxException: Thread blocked warnings when the library contained many packs, especially with a large unofficial metadata database.

Three compounding issues in the packs() request path:

  • DatabaseMetadataService re-read and re-parsed the entire unofficial metadata database file from disk on every single pack lookup, and rewrote the whole file on every refresh, instead of caching it in memory like the official database already was.
  • LibraryService.packs() read the most recent pack file of every group a second time to refresh its metadata, bypassing the existing short-lived pack cache and duplicating disk reads.
  • ArchiveStoryPackReader.readMetadata used a sequential zip stream, which has to inflate every asset entry just to skip past it, even though only story.json and thumbnail.png are needed. Switched to random-access reads via the zip's central directory.

Fixes #603

Test plan

Verified against a real local library (249 pack files, ~46 unofficial database entries, 18.5 MB unofficial.json) by building the full distribution and measuring GET /api/library/packs:

  • Before: repeated Thread blocked warnings (60s-260s+ per block), library load in the multiple-minutes range
  • After: cold load ~3.4s with zero blocked-thread warnings, cached reload ~0.3s
  • Full mvn clean install build passes

The local library screen could take minutes to load and spam the console
with `io.vertx.core.VertxException: Thread blocked` warnings when the
library contained many packs, especially with a large unofficial metadata
database.

Three compounding issues in the packs() request path:

- DatabaseMetadataService re-read and re-parsed the entire unofficial
  metadata database file from disk on every single pack lookup, and
  rewrote the whole file on every refresh, instead of caching it in
  memory like the official database already was.
- LibraryService.packs() read the most recent pack file of every group
  a second time to refresh its metadata, bypassing the existing
  short-lived pack cache and duplicating disk reads.
- ArchiveStoryPackReader.readMetadata used a sequential zip stream,
  which has to inflate every asset entry just to skip past it, even
  though only story.json and thumbnail.png are needed. Switched to
  random-access reads via the zip's central directory.

Fixes marian-m12l#603
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lecture de bibliothèque lente: io.vertx.core.VertxException: Thread blocked

1 participant