Repository navigation
perf(daily): parallelize week-window fetch + stop refresh firing at board-open - #914
Merged
Merged
Conversation
…oard-open The Daily hub's enable window dragged and it re-fetched too often. (a) Enable latency: fetchWeekWindow issued 7 CloudKit round-trips in a serial for-loop (MS: 8, window→failed sequential). Both now fan out via withThrowingTaskGroup; results re-sorted by offsetFromToday so the week strip order is preserved, and MS runs bestTimes/window/failed as three concurrent async-let lanes. WeekWindowSlot is Sendable; persistence is captured as a local let before the group (actors serialize at the mailbox, no deadlock); degrade-on-failure semantics unchanged. (b) Over-frequent fetch: .onChange(of: sessionTeardownCount) re-ran the full fetch, and the counter over-fired — GameBoardRedirect's synthetic path-pop at board OPEN shrank path exactly like a close. GameBoardRedirect now calls onPresent (→ isGamePresented=true) before popping, and the new GameRootViewModel.handlePathShrink guards !isGamePresented so the open-time shrink is filtered — refresh() no longer fires at board open. macOS (onPresentBoard nil) is unaffected: isGamePresented stays false so every path-shrink still bumps as before; genuine iOS close goes through the separate dismissGame() path, untouched. Tests: gated-fake concurrency tests assert callCount reaches 7 (MS 8) before unlock (deadlocks on the old serial loop) + week-strip order [6..0]; 3 open-vs-close tests assert no bump at open, bump at close. Sudoku's GatedWeekWindowPersistence fake converted single-continuation → queue (parity with MS's #886 GatedQueryGateway) to hold 7 concurrent in-flight calls. Dual CR: APPROVE-with-cosmetic x2 (stale gameSessionDidTearDown doc corrected here; MS-only failed-ids lane is an inherent app difference). Closes #912 Co-Authored-By: Claude Fable 5 <[email protected]>
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.
What
Two Daily-hub performance fixes (owner-reported: enable window too long + fetch too frequent).
withThrowingTaskGroupfan-out, results re-sorted byoffsetFromTodayto preserve week-strip order; MS runs bestTimes/window/failed as 3 concurrentasync letlanes.sessionTeardownCountover-fired becauseGameBoardRedirect's synthetic path-pop at OPEN shrankpathlike a close. NewhandlePathShrinkguards!isGamePresented;GameBoardRedirectnow presents before popping, so the open-time shrink is filtered.Why
The enable window was bound by 7 serial CK round-trips; the fetch re-ran on every teardown bump, and the counter double-counted board-open as a session-end. Both facets share one root: full uncached re-fetch triggered too liberally.
Verification
callCountreaches 7 (MS 8) before unlock — deadlocks on the old serial loop — plus week-strip order [6..0].dismissGame).swift testGameAppKit / SudokuKit Daily / MinesweeperKit all green;swiftlint --strictclean.Scoped out (flagged for a follow-up issue): MS's
fetchCompletedDailyIdsissues 7 identical CK queries (no date predicate, client-side filtered) — parallelized here but the query-dedup is a deeper caching change. Client-side caching of immutable older days also deferred.Closes #912
🤖 Generated with Claude Code