perf: fast home and search via canonical readmodel sync and session bypass #9

Merged
Wuast94 merged 3 commits from perf/canonical-readmodel-fast-home-search into main 2026-10-20 11:07:33 +02:00
Owner

Summary

This PR addresses the slow Jellyfin-Web initial page load and search requests by removing request-time executor delays, optimizing warm session authentications, completing canonical readmodel derivations and writer synchronizations, and streamlining Views and Search execution.

Key Changes

  1. HTTP Core & Session (perf(http)):
    • normalize_routes: Replaced asynchronous CPU executor dispatch with synchronous in-memory URI canonicalization in Tokio. Added immediate 503 Service Unavailable check during process cancellation.
    • SessionRegistry: Added zero-allocation in-memory lookup methods session_for_key and capabilities_for_device.
    • RequestContextBuilder: Authenticated warm requests directly verify session in-memory, updating access timestamp without querying database tables (device_options, image_tags) or dispatching reserve_login/commit tasks.
  2. Canonical Readmodel Mutators & Derivations (feat(readmodel)):
    • builder.rs: Implemented extraction and calculation of premiere_date, query_rating, query_subrating, acl_unrated_mask, acl_max_rating, and acl_max_subrating.
    • sync.rs: Added batch resolution of version library mappings, owned parts (AdditionalPart), tag inheritance across hierarchy (items, parents, grandparents), and ancestor ACL ratings.
    • Mutator synchronization: Added transactional canonical fact updates to scanned media (only on actual change), composition writes (sync_search_facts_for_compositions), metadata updates (sync_search_facts_for_named and sync_search_facts_for_compositions), named item relations, and remaining source cleanup.
  3. Views & Search Acceleration (perf(home)):
    • Views (view_factory.rs): Replaced GET-time mutate_composition write transactions with read-first checks via create_composition.
    • Views catalog (views/catalog.rs): Avoids unrestricted composition loading (Uuid::nil()) by querying specific candidate IDs for requested view kinds.
    • Search hints (compact.rs): Preserved named metadata search execution while short-circuiting empty candidate sets.

Verification

  • cargo clippy --workspace --all-targets -- -D warnings: 0 warnings, 0 errors.
  • RUSTFIN_TEST_COMPILER_CACHE=off just gate: All checks (architecture, fmt-check, clippy, integration test across isolated PostgreSQL, deny, machete) passed cleanly.
  • just domain-test identity_api_tests: 145 passed; 0 failed.
## Summary This PR addresses the slow Jellyfin-Web initial page load and search requests by removing request-time executor delays, optimizing warm session authentications, completing canonical readmodel derivations and writer synchronizations, and streamlining Views and Search execution. ### Key Changes 1. **HTTP Core & Session (`perf(http)`)**: - `normalize_routes`: Replaced asynchronous CPU executor dispatch with synchronous in-memory URI canonicalization in Tokio. Added immediate 503 Service Unavailable check during process cancellation. - `SessionRegistry`: Added zero-allocation in-memory lookup methods `session_for_key` and `capabilities_for_device`. - `RequestContextBuilder`: Authenticated warm requests directly verify session in-memory, updating access timestamp without querying database tables (`device_options`, `image_tags`) or dispatching `reserve_login`/`commit` tasks. 2. **Canonical Readmodel Mutators & Derivations (`feat(readmodel)`)**: - `builder.rs`: Implemented extraction and calculation of `premiere_date`, `query_rating`, `query_subrating`, `acl_unrated_mask`, `acl_max_rating`, and `acl_max_subrating`. - `sync.rs`: Added batch resolution of version library mappings, owned parts (`AdditionalPart`), tag inheritance across hierarchy (items, parents, grandparents), and ancestor ACL ratings. - Mutator synchronization: Added transactional canonical fact updates to scanned media (only on actual change), composition writes (`sync_search_facts_for_compositions`), metadata updates (`sync_search_facts_for_named` and `sync_search_facts_for_compositions`), named item relations, and remaining source cleanup. 3. **Views & Search Acceleration (`perf(home)`)**: - Views (`view_factory.rs`): Replaced GET-time `mutate_composition` write transactions with read-first checks via `create_composition`. - Views catalog (`views/catalog.rs`): Avoids unrestricted composition loading (`Uuid::nil()`) by querying specific candidate IDs for requested view kinds. - Search hints (`compact.rs`): Preserved named metadata search execution while short-circuiting empty candidate sets. ### Verification - `cargo clippy --workspace --all-targets -- -D warnings`: 0 warnings, 0 errors. - `RUSTFIN_TEST_COMPILER_CACHE=off just gate`: All checks (`architecture`, `fmt-check`, `clippy`, integration `test` across isolated PostgreSQL, `deny`, `machete`) passed cleanly. - `just domain-test identity_api_tests`: 145 passed; 0 failed.
Wuast94 deleted branch perf/canonical-readmodel-fast-home-search 2026-10-20 11:07:35 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Wuast94/rustfin!9
No description provided.