Skip to content

perf(gateway): reduce redundant live overview updates - #1039

Merged
nixuuu merged 2 commits into
devfrom
canopy/mam-problem-3ana
Nov 19, 2026
Merged

nixuuu merged 2 commits into
devfrom
canopy/mam-problem-3ana

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Change

A cached pull request read could publish thread and overview updates for every linked thread in its repository. Selecting another active thread could also restart the shared overview twice and fetch two full snapshots. A slow overview subscriber could then reach its 256-frame limit while little data was queued.

  • Scope PR updates to active links for that owner and PR. Repair stale projections on cache hits. Re-read under the thread row lock so a concurrent unlink cannot restore a removed link in the sidebar. Refresh open lists when an older PR changes.
  • Send changed bot summaries and preserve pending approvals and execution state across partial bot replies. Limit the project updates generated by worker status reports while keeping workspace origin and scratch placement discovery.
  • Keep the upstream overview open for a 500 ms renderer handover and replay authorized head cursors to the new subscriber.
  • Compact a slow overview queue only at its existing item or byte limit. Keep ordering around state transitions and controls. An irreducible queue still reports DataLoss and can recover from a new snapshot.

Migration 0177 initializes a per-link summary fingerprint for current active links. It keeps concurrent readers of the same PR from increasing a thread’s list revision repeatedly.

Verification

An isolated repository with 439 linked threads, including five linked to the measured PR, reproduced the fan-out. One warm GetPullRequest made 439 projection calls, read 439 thread rows and produced 878 hub publications before the change. Each count fell to zero, with the same PR returned and no GitHub HTTP request in either run. One local RPC took 247.7 ms before and 6.7 ms after.

On the original gateway a two-thread burst of 300 worker events terminated the stalled overview with DataLoss. The fixed gateway delivered both final states, persisted all 300 events in order and replayed both completed responses from pre-burst checkpoints. Separate cases exercise item and byte overflow with nonreplaceable frames, and delivery to a healthy observer.

Five renderer handovers with the same subscriptions produced ten additional snapshots before and zero after. Real PostgreSQL and gRPC integration coverage exercises independent PRs in the same repository, shared links, concurrent unlink, older PRs, cache repair, account changes, bot feeds, disconnection, worker replay and lost acknowledgements.

With five projects and 16 status reports, the original gateway published 80 project frames. The fixed gateway published zero, issued zero project list queries and delivered all 16 worker updates. The same suite verifies changed Git origins, retry after a failed read and a new worker’s scratch placement.

Production renderer in Chromium, isolated gateway, BFF and PostgreSQL. Seven bot conversation switches opened no additional overview SSE. A pending approval survived navigation and reload and sent exactly one worker response. Checked light and dark at desktop and phone widths.

Fixes: #501
Fixes: #847
Fixes: #458

Scope pull request, bot and worker updates and keep renderer subscriptions across short navigation handovers. Preserve resumable thread history and terminal state transitions when compacting a slow overview reader.

Fixes: #501
Fixes: #847
Fixes: #458
@nixuuu
nixuuu marked this pull request as ready for review November 19, 2026 18:32
@nixuuu
nixuuu enabled auto-merge (squash) November 19, 2026 18:33
@nixuuu
nixuuu merged commit c191025 into dev Nov 19, 2026
16 checks passed
@nixuuu
nixuuu deleted the canopy/mam-problem-3ana branch November 19, 2026 18:52
nixuuu added a commit that referenced this pull request Nov 24, 2026
## Change

- Publish the updated thread overview after individual or batched
background refreshes of linked pull requests. The sidebar and Thread
details now show the same PR state once the gateway detects a merge.
- Reconcile a previously cached status on list reads, including an
already-merged PR. Reconciliation uses the existing cache and
publication path.

Fixes: #1039

## Verification

- Reproduced the missing overview update before the fix in three gRPC
regression cases covering single refresh, batched refresh, and an
already-cached merge.
- Ran 24 integration tests through `check:tmp`, the gateway typecheck,
and lint on edited files. An existing account-switch test failed once,
then passed in isolation and in the final 24-test run.
- Verified in desktop-width Chromium with an isolated gateway that
Thread details and the sidebar switched from Open to Merged without a
reload.
- Repository-wide checks remain with CI.
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