Skip to content

perf(runtime): bound caches, scans, and background work - #564

Open
beruro wants to merge 7 commits into
junyu/async-resource-lifecyclefrom
junyu/runtime-resource-bounds
Open

perf(runtime): bound caches, scans, and background work#564
beruro wants to merge 7 commits into
junyu/async-resource-lifecyclefrom
junyu/runtime-resource-bounds

Conversation

@beruro

@beruro beruro commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Problem

Repository, project, sidebar, benchmark, file-index, and webview paths could duplicate in-flight work, retain unbounded cache/surface state, miss authoritative invalidation, or continue hidden background work beyond the owning lifecycle.

Solution

  • Coordinate equivalent reads with retryable single-flight ownership and scope-fence late results.
  • Bound file-index/project caches and connect invalidation to authoritative git/project mutations.
  • Suspend hidden webview/layout work and cap retained browser surfaces.
  • Throttle/coalesce deleted-work-item purge operations.
  • Integrate the latest refactor(async): add scoped resource lifecycle #562 base while preserving its newer view-scoped project reads and the current sidebar entity/cursor/generation model.
  • Keep sidebar coordinators owned per Jotai store so multiple windows do not share mutable lifecycle state.

The updated branch is based on the current #562 head and GitHub reports it mergeable.

Potential risks

  • This is a broad performance/lifecycle sweep; cache invalidation, failed-owner retry, scope identity, and repeated open/close behavior remain the highest-risk paths.
  • The sidebar merge combines this PR's single-flight ownership with the newer authoritative roster cursor model. Targeted tests cover overlap, forced refresh, scope changes, pagination generations, and imported-source failures, but full desktop multi-window behavior still relies on CI/E2E coverage.
  • Project purge state is bounded to 50 projects and throttled for five minutes; an explicit later purge within that interval returns zero by design.
  • This PR depends on refactor(async): add scoped resource lifecycle #562 and should merge/retarget only after refactor(async): add scoped resource lifecycle #562. Rollback is a normal revert after its base lands; no schema, wire, or persistence migration is involved.

Performance audit

Verdict: pass. Active operations keep one owner per scope/store, equal requests coalesce, stronger/scope-changing requests queue one trailing run, late generations cannot publish, caches/surfaces have explicit caps, hidden work suspends, and invalidation is tied to authoritative mutations rather than a new polling loop.

Verification

  • ./node_modules/.bin/vitest run src/api/http/project/client.purge.test.ts src/store/session/sessionAtom/__tests__/sidebarLoaders.test.tsPASS, 2 files / 29 tests.
  • ./node_modules/.bin/eslint on the four integration-conflict/test files — PASS, no errors or warnings.
  • ./node_modules/.bin/tsc --noEmit --pretty falsePASS.
  • git diff --checkPASS.
  • Merge of the updated refactor(async): add scoped resource lifecycle #562 branch — PASS after semantic conflict resolution; final diff remains limited to the original 40 performance-lifecycle files.
  • Full repository CI is running on the published merge commit.

@beruro
beruro force-pushed the junyu/async-resource-lifecycle branch from 9c4d6e6 to eb16aff Compare July 30, 2026 07:07
@beruro
beruro force-pushed the junyu/runtime-resource-bounds branch from 87c9201 to 7d574a2 Compare July 30, 2026 07:07
@beruro
beruro force-pushed the junyu/async-resource-lifecycle branch from eb16aff to 59189c0 Compare July 30, 2026 07:49
@beruro
beruro force-pushed the junyu/runtime-resource-bounds branch from 7d574a2 to cbb7a55 Compare July 30, 2026 07:49
@beruro
beruro force-pushed the junyu/async-resource-lifecycle branch from 59189c0 to a739c82 Compare July 30, 2026 08:04
@beruro
beruro force-pushed the junyu/runtime-resource-bounds branch from cbb7a55 to 3b7055f Compare July 30, 2026 08:04
@beruro
beruro force-pushed the junyu/async-resource-lifecycle branch from a739c82 to d16c8e5 Compare July 30, 2026 15:09
beruro and others added 2 commits August 8, 2026 20:51
…e-lifecycle' into HEAD

# Conflicts:
#	src/api/http/project/client.ts
#	src/modules/ProjectManager/WorkItems/hooks/useWorkItemsData.ts
#	src/store/session/sessionAtom/loaders.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant