perf(import-lists): optimize local library lookup and defer Hardcover cursor commit - #101
Open
Josh-Archer wants to merge 2 commits into
Open
perf(import-lists): optimize local library lookup and defer Hardcover cursor commit#101Josh-Archer wants to merge 2 commits into
Josh-Archer wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR addresses two related performance and data-integrity issues in the import list subsystem:
ImportListSyncService.BuildImportListLocalLookup()previously performed full-table scans across the entire library (GetAllAuthors()andGetAllBooks()) on every list sync pass. On large libraries (thousands of books), this caused multi-minute CPU spikes and database contention. This change scopes the local lookup strictly to the batch of item provider IDs fetched during the current sync pass.CommitState):HardcoverLibraryImportList.Fetch()previously updated the sync cursor in the database immediately upon receiving the API response. If downstream processing failed (disk error, validation failure, or unhandled exception duringProcessListItems), the cursor had already moved forward, permanently dropping un-imported books. This change introducesCommitState()to theIImportList/ImportListBaselifecycle, ensuring state and cursors are persisted only after list items are successfully processed.Database Migration
NO
How was this tested?
HardcoverLibraryImportListCursorFixturetesting cursor non-persistence duringFetch()and proper persistence onCommitState().ImportListSyncServiceSearchOnAddFixturepasses with the updated scoped local lookup.Highlights & Assumptions
CommitState()implementation onImportListBaseensures zero breaking changes for existing or third-party import list implementations._authorService.FindByProviderIdand_bookService.FindByProviderId.CommitState()pattern.AI Disclosure & Workflow Sharing