[PR #5123] [CLOSED] perf: improve large-library browse performance #4436

Closed
opened 2026-04-25 00:19:44 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/5123
Author: @jonathanfinley
Created: 3/14/2026
Status: Closed

Base: masterHead: pr/upstream-large-library-performance


📝 Commits (10+)

  • c55361c test: add browse instrumentation helpers
  • da49060 fix: wire browse request timing hooks
  • 1533d41 test: define large-library browse strategy contract
  • 8585cff fix: align large-library browse strategy keys
  • 59c7c0a fix: restore updated browse keyset coverage
  • 36170d0 test: add deterministic browse cursor helpers
  • f24bd19 fix: harden browse cursor validation
  • 6b7550c fix: reject non-object browse cursors
  • 3579341 feat: add large-library browse response contract
  • d28d96f test: fix browse request option forwarding coverage

📊 Changes

26 files changed (+3926 additions, -420 deletions)

View changed files

📝 client/components/app/LazyBookshelf.vue (+189 -22)
client/cypress/tests/components/app/LazyBookshelf.cy.js (+245 -0)
📝 server/Database.js (+38 -0)
📝 server/controllers/LibraryController.js (+49 -11)
📝 server/managers/BinaryManager.js (+2 -2)
server/migrations/v2.32.6-large-library-browse-indexes.js (+213 -0)
📝 server/models/LibraryItem.js (+24 -3)
📝 server/scanner/LibraryItemScanner.js (+2 -0)
📝 server/scanner/LibraryScanner.js (+6 -2)
📝 server/utils/libraryHelpers.js (+96 -219)
📝 server/utils/profiler.js (+93 -9)
server/utils/queries/libraryBrowseCount.js (+21 -0)
server/utils/queries/libraryBrowseCursor.js (+38 -0)
server/utils/queries/libraryBrowseInstrumentation.js (+89 -0)
server/utils/queries/libraryBrowseStrategy.js (+108 -0)
📝 server/utils/queries/libraryFilters.js (+67 -109)
📝 server/utils/queries/libraryItemsBookFilters.js (+752 -39)
📝 server/utils/queries/libraryItemsPodcastFilters.js (+49 -4)
test/server/controllers/LibraryController.largeLibraryBrowse.test.js (+1055 -0)
📝 test/server/managers/BinaryManager.test.js (+28 -0)

...and 6 more files

📄 Description

Summary

  • add a large-library browse contract with live instrumentation, deterministic cursor pagination, and split row/count loading for the main book browse paths
  • replace expensive correlated browse predicates, add matching browse indexes, and keep collapsed-series browse bounded while preserving collapsed payload semantics
  • update LazyBookshelf to use cursor-aware endless scroll and explicitly cap offset-only fallback modes

Test Plan

  • npm test -- test/server/utils/libraryBrowseInstrumentation.test.js test/server/utils/libraryBrowseCursor.test.js test/server/utils/libraryBrowseStrategy.test.js test/server/utils/libraryBrowseCount.test.js test/server/controllers/LibraryController.largeLibraryBrowse.test.js test/server/migrations/v2.32.6-large-library-browse-indexes.test.js test/server/managers/BinaryManager.test.js
  • npm test -- test/server/migrations/v2.19.4-improve-podcast-queries.test.js test/server/migrations/v2.20.0-improve-author-sort-queries.test.js
  • cd client && npm test -- --spec cypress/tests/components/app/LazyBookshelf.cy.js
  • TEST_POSTGRES_URL=... npm test -- test/server/migrations/v2.32.6-large-library-browse-indexes.postgres.test.js (not run here)
  • npx eslint server on upstream branch is currently blocked by pre-existing unrelated lint errors in upstream files such as server/managers/BackupManager.js, server/utils/podcastUtils.js, and server/utils/scandir.js

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/5123 **Author:** [@jonathanfinley](https://github.com/jonathanfinley) **Created:** 3/14/2026 **Status:** ❌ Closed **Base:** `master` ← **Head:** `pr/upstream-large-library-performance` --- ### 📝 Commits (10+) - [`c55361c`](https://github.com/advplyr/audiobookshelf/commit/c55361c552858d88d9576ec8ae53995080f1a628) test: add browse instrumentation helpers - [`da49060`](https://github.com/advplyr/audiobookshelf/commit/da490605b7312e85055948a0e68386fa8445b22e) fix: wire browse request timing hooks - [`1533d41`](https://github.com/advplyr/audiobookshelf/commit/1533d4146a806df7ae8e421f9adb5e164282dd3a) test: define large-library browse strategy contract - [`8585cff`](https://github.com/advplyr/audiobookshelf/commit/8585cfff6bad60e86518385be5ab88d0e63360a2) fix: align large-library browse strategy keys - [`59c7c0a`](https://github.com/advplyr/audiobookshelf/commit/59c7c0a7c2277644eff96a3a901c65af4e5e98b7) fix: restore updated browse keyset coverage - [`36170d0`](https://github.com/advplyr/audiobookshelf/commit/36170d0fcb0d3f8a1dd52f32feb86cb88f645a12) test: add deterministic browse cursor helpers - [`f24bd19`](https://github.com/advplyr/audiobookshelf/commit/f24bd19cb7e4fa18b9f287d0be1714b618db9bb4) fix: harden browse cursor validation - [`6b7550c`](https://github.com/advplyr/audiobookshelf/commit/6b7550c25b8a7d0f4321878d79b109397692da9d) fix: reject non-object browse cursors - [`3579341`](https://github.com/advplyr/audiobookshelf/commit/3579341f6c32fdae88f4dc0228001b187dbb93e9) feat: add large-library browse response contract - [`d28d96f`](https://github.com/advplyr/audiobookshelf/commit/d28d96ff949ab01aebea371db0da2fc6c8601a0e) test: fix browse request option forwarding coverage ### 📊 Changes **26 files changed** (+3926 additions, -420 deletions) <details> <summary>View changed files</summary> 📝 `client/components/app/LazyBookshelf.vue` (+189 -22) ➕ `client/cypress/tests/components/app/LazyBookshelf.cy.js` (+245 -0) 📝 `server/Database.js` (+38 -0) 📝 `server/controllers/LibraryController.js` (+49 -11) 📝 `server/managers/BinaryManager.js` (+2 -2) ➕ `server/migrations/v2.32.6-large-library-browse-indexes.js` (+213 -0) 📝 `server/models/LibraryItem.js` (+24 -3) 📝 `server/scanner/LibraryItemScanner.js` (+2 -0) 📝 `server/scanner/LibraryScanner.js` (+6 -2) 📝 `server/utils/libraryHelpers.js` (+96 -219) 📝 `server/utils/profiler.js` (+93 -9) ➕ `server/utils/queries/libraryBrowseCount.js` (+21 -0) ➕ `server/utils/queries/libraryBrowseCursor.js` (+38 -0) ➕ `server/utils/queries/libraryBrowseInstrumentation.js` (+89 -0) ➕ `server/utils/queries/libraryBrowseStrategy.js` (+108 -0) 📝 `server/utils/queries/libraryFilters.js` (+67 -109) 📝 `server/utils/queries/libraryItemsBookFilters.js` (+752 -39) 📝 `server/utils/queries/libraryItemsPodcastFilters.js` (+49 -4) ➕ `test/server/controllers/LibraryController.largeLibraryBrowse.test.js` (+1055 -0) 📝 `test/server/managers/BinaryManager.test.js` (+28 -0) _...and 6 more files_ </details> ### 📄 Description ## Summary - add a large-library browse contract with live instrumentation, deterministic cursor pagination, and split row/count loading for the main book browse paths - replace expensive correlated browse predicates, add matching browse indexes, and keep collapsed-series browse bounded while preserving collapsed payload semantics - update `LazyBookshelf` to use cursor-aware endless scroll and explicitly cap offset-only fallback modes ## Test Plan - [x] `npm test -- test/server/utils/libraryBrowseInstrumentation.test.js test/server/utils/libraryBrowseCursor.test.js test/server/utils/libraryBrowseStrategy.test.js test/server/utils/libraryBrowseCount.test.js test/server/controllers/LibraryController.largeLibraryBrowse.test.js test/server/migrations/v2.32.6-large-library-browse-indexes.test.js test/server/managers/BinaryManager.test.js` - [x] `npm test -- test/server/migrations/v2.19.4-improve-podcast-queries.test.js test/server/migrations/v2.20.0-improve-author-sort-queries.test.js` - [x] `cd client && npm test -- --spec cypress/tests/components/app/LazyBookshelf.cy.js` - [ ] `TEST_POSTGRES_URL=... npm test -- test/server/migrations/v2.32.6-large-library-browse-indexes.postgres.test.js` (not run here) - [ ] `npx eslint server` on upstream branch is currently blocked by pre-existing unrelated lint errors in upstream files such as `server/managers/BackupManager.js`, `server/utils/podcastUtils.js`, and `server/utils/scandir.js` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:19:44 +02:00
adam closed this issue 2026-04-25 00:19:44 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#4436