Skip to content

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

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

perf(runtime): bound caches, scans, and background work#564
beruro wants to merge 15 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, webview, git-watcher, Kanban impact, and Git History 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 fence late results by scope.
  • Bound project/file-index caches, retained browser surfaces, Git watchers, Kanban summaries, and automatic Git History filter expansion.
  • Suspend hidden webview/layout work and throttle/coalesce deleted-work-item purges.
  • Keep sidebar coordinators owned per Jotai store so multiple windows do not share mutable lifecycle state.
  • Keep this PR stacked directly on refactor(async): add scoped resource lifecycle #562 and independent from sibling refactor(data): scope async resource consumers #563.

Potential risks

  • Cache invalidation, failed-owner retry, scope identity, and repeated open/close behavior remain the highest-risk paths.
  • Protected or busy repositories can temporarily keep the watcher count above 20 until a later registration finds an idle eviction candidate.
  • Kanban still receives the full orgtrack RPC payload transiently before projecting it to the visible roster.
  • Git History automatically searches only the newest 500 commits; older matches require explicit user action.
  • This PR depends on refactor(async): add scoped resource lifecycle #562 and should be retargeted only after refactor(async): add scoped resource lifecycle #562 lands. Rollback is a normal revert; there is no schema, wire, or persistence migration.

Performance audit

Verdict: pass with documented safety valves. Active operations keep one owner per scope/store, equal requests coalesce, late generations cannot publish, retained caches/surfaces have explicit caps, and hidden work suspends.

Verification

Validated locally after merging current #562 head 8618af370 into head 98e9304de without conflicts:

  • pnpm install --frozen-lockfilePASS. The optional legacy node-sass native postinstall warning did not block installation or checks.
  • Focused Vitest across all 13 changed test files — PASS, 13 files / 81 tests.
  • pnpm typecheckPASS.
  • cargo test -p git watch::tests::watcher_tests -- --nocapturePASS, 17 tests.
  • git diff --cached --check before the merge commit — PASS.

Because this stacked PR targets junyu/async-resource-lifecycle, full frontend/Rust CI may not run until #562 lands and this PR is retargeted to develop.

UI evidence

The Git History capped state uses the existing placeholder action composition. No new visual change was introduced by this base merge; focused state-transition tests cover when the action appears.

@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 added 2 commits July 30, 2026 23:09
Pre-commit hook ran. Total eslint: 10, total circular: 0
Pre-commit hook ran. Total eslint: 10, total circular: 0
@beruro
beruro force-pushed the junyu/async-resource-lifecycle branch from a739c82 to d16c8e5 Compare July 30, 2026 15:09
beruro and others added 4 commits August 8, 2026 20:38
…e-lifecycle' into HEAD

# Conflicts:
#	src/api/http/project/client.ts
#	src/modules/ProjectManager/WorkItems/hooks/useWorkItemsData.ts
#	src/store/session/sessionAtom/loaders.ts
@beruro
beruro marked this pull request as draft August 10, 2026 03:35
@beruro
beruro force-pushed the junyu/async-resource-lifecycle branch 2 times, most recently from fb403e6 to 5f991c2 Compare August 10, 2026 05:24
@beruro
beruro marked this pull request as ready for review August 11, 2026 05:16
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