Repository navigation
perf(backend): wire the effective-project cache and move it off BigCache (WI-1964) - #443
Merged
Merged
Conversation
…e (WI-1964) ItemCacheService existed to cache the resolved effective project for an item but was never wired: GetEffectiveProjectForItem had no caller, and the item read path ran the recursive parent-chain CTE on every detail read. WarmCache was a no-op. - Replace the BigCache store with cacheutil.TypedCache (sharded, TTL, count-bounded, registered for /admin/diagnostics/cache-memory), the same call WI-1906 made for the permission snapshot cache. No JSON on the read path. - Wire ItemCRUDService.GetWithEffectiveProject through the cache when one is injected; ItemApplicationService.WithCache passes the shared cache down. The uncached resolver stays the fallback and shares ResolveEffectiveProject as the single source of truth. - Make WarmCache actually populate entries (bounded by WarmupBatchSize, still backgrounded) instead of a no-op loop. - Drop the unused GetItemHierarchy/SetItemHierarchy/ItemHierarchyCache surface and the per-call repo allocation. Invalidation is unchanged: mutation paths already invalidate the item and its descendants.
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.
Why
ItemCacheServiceexists to cache the resolved effectiveproject_idfor an item so a read doesn't re-walk the parent chain, but it was never wired:GetEffectiveProjectForItem(the only reader/writer of the cache) had no caller.ItemApplicationService.Get→ItemCRUDService.GetWithEffectiveProject— calledResolveEffectiveProjectdirectly, running the recursive CTE (up to 10 levels) on every item-detail read.WarmCachewas a no-op (_ = itemID).What
cacheutil.TypedCache[effectiveProjectCacheEntry]— sharded, per-entry TTL with sweep, count-bounded, registered for/admin/diagnostics/cache-memory. Same call WI-1906 made for the permission snapshot cache: cardinality is items and the value is a small struct, so the byte API only added marshal/copy overhead.ItemCRUDServicegains an optional cache +WithCache;GetWithEffectiveProjectresolves through it.ItemApplicationService.WithCachepasses the shared cache down tos.crud. Without a cache the uncached resolver is used, and both shareResolveEffectiveProjectas the single source of truth.WarmupBatchSize, still backgrounded).GetItemHierarchy/SetItemHierarchy/ItemHierarchyCachesurface and the per-call repo allocation;NewItemCacheServiceno longer returns an error.Invalidation is unchanged — mutation paths already invalidate the item and its descendants.
Acceptance
project_id/inherit_project/parent_idmakes affected items resolve fresh (existing invalidation, asserted in the new tests).TypedCache.Verification
go build ./internal/...,go vet,golangci-linton the changed packages — 0 issuesinternal/services/...— pass except the pre-existingTestItemWorkspaceMovePreviewsAndCommitsExactPolicy(fails onmain)internal/handlers/...— pass except two pre-existingTestNeutralInferenceEndpoint...failures (fail onmain)Note: verification ran from a clean core-tests worktree because the shared core-tests checkout has another session's uncommitted
email_reply_servicechanges (which reference a core field not yet onmain).Pairs with Windshiftapp/core-tests-internal#36.