Repository navigation
Conversation
…navigation) - Scope A: Replace series.episodes relationship traversal in NextEpisodeResolver with bounded LIMIT 1 fetches. Added composite index on (series, seasonNum, episodeNum) and covering migration in CatalogIndexBackfill to ensure indexed B-tree lookups without temporary sorting. - Scope B: Implement bounded RingCache in LiveChannelNavigator to avoid repeated channel positional sort and bisection passes on warm navigation while preserving exact SQLite collation, ties, NULL handling, and ring wrap. Invalidate on context saves. - Benchmark: Episode resolution reduced from 0.570s to 0.149s with zero retained memory growth (peak RSS dropped by 22MB). Channel surf resolution dropped from 6.027s to 0.032s (~188x faster).
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.
Summary
series.episodesrelationship traversal inNextEpisodeResolverwith targetedLIMIT 1fetches for both adjacent episode and season boundary transitions.#Index<Episode>([\.series, \.seasonNum, \.episodeNum])onEpisodeand migration covering indexZ_Episode_SwiftDataIndexOnBinaryseriesSeasonEpisodeinCatalogIndexBackfillto allow direct SQLite index seeks without temporary B-tree sorting.RingCacheinLiveChannelNavigator(bounded to 6 scopes, max 2,048 entries per scope, < 1 MB memory) invalidated on context saves (ModelContext.didSave/NSManagedObjectContextDidSave). Preserves exact localized collation (COLLATE NSCollateFinderlike), ties, NULL handling, ring wrap, and profile restrictions.Performance Measurements
Verified on
BrowseQueryBenchmarks:testSeriesEpisodeResolution):0.570 s->0.149 s(~3.8x faster)66.3 MB->44.3 MB(22 MB reduction)9.2 MB->0.0 MB(zero retained growth)testChannelSurfResolution):6.027 s->0.032 s(~188x faster / ~99.5% reduction)0.0 MBTesting
NextEpisodeResolverTests,LiveChannelNavigatorTests,LiveChannelNavigatorCollationTests,BrowseQueryShapeTests.NextEpisodeResolverTestscovering duplicate episode positions and non-consecutive season gaps.