Skip to content

perf(sync-service): batch cold shape startup work#4647

Open
joshdchang wants to merge 1 commit into
electric-sql:alco/ets-inspector-mailbox-floodingfrom
ai-sapien:sapien/batch-cold-shape-startup-upstream
Open

perf(sync-service): batch cold shape startup work#4647
joshdchang wants to merge 1 commit into
electric-sql:alco/ets-inspector-mailbox-floodingfrom
ai-sapien:sapien/batch-cold-shape-startup-upstream

Conversation

@joshdchang

Copy link
Copy Markdown

Summary

This is stacked on #4588 and targets its branch so the inspector-cache work can be reviewed separately.

When many shapes for previously unseen relations start together, they currently serialize repeated catalog and publication work. This change:

  • loads cold relation metadata in batches rather than issuing one catalog query per relation
  • batches publication additions and replica-identity updates in one transaction
  • tracks the in-flight relation set so overlapping refreshes do not resubmit the same work
  • falls back to the existing per-relation path if a batch update fails

It does not increase startup or snapshot timeouts.

Evidence

On local PostgreSQL 18 with 40 distinct one-row tables requested concurrently from a cold Electric instance:

Runtime Wall Median p95 Max
upstream 1.7.3 0.495s 0.404s 0.479s 0.485s
this branch 0.171s 0.129s 0.168s 0.169s

All 40 requests returned HTTP 200. A repeated warm fanout completed in 0.024s wall time.

Validation on the latest-main integration branch:

  • 1,843 tests, 391 doctests, and 9 properties; 0 failures
  • focused relation, publication, router lifecycle, PgBouncer, and streaming coverage passes

Validation on this stacked branch:

  • 92 focused tests; 0 failures

Review notes

The latest-main integration branch also contains post-#4588 connection-error normalization that this stacked change relies on. Once #4588 is rebased or merged, this PR should be rebased and retargeted to main before merge.

@joshdchang joshdchang marked this pull request as ready for review June 23, 2026 21:12
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