Skip to content

perf(desktop): reduce startup load time by ~95%#1650

Open
justsomelegs wants to merge 6 commits intopingdotgg:mainfrom
justsomelegs:legs/startup-perf
Open

perf(desktop): reduce startup load time by ~95%#1650
justsomelegs wants to merge 6 commits intopingdotgg:mainfrom
justsomelegs:legs/startup-perf

Conversation

@justsomelegs
Copy link
Copy Markdown

@justsomelegs justsomelegs commented Apr 1, 2026

What Changed

  • bootstrap the orchestration engine from projections instead of replaying the full event log on every launch
  • keep full event replay as a fallback if the projection snapshot is missing or incomplete
  • stop loading thread activities into the in-memory engine bootstrap state
  • replace a few startup-time full snapshot reads with targeted projection queries
  • bootstrap the UI from a compact orchestration snapshot first, then hydrate the heavier full snapshot afterward
  • fall back to the full snapshot if compact bootstrap fails during initial load

So instead of:

  • replaying all historical orchestration events
  • fetching the full read model immediately just to render the initial UI

startup now:

  • restores engine state from projections
  • loads a compact snapshot for the sidebar / initial shell
  • fills in the heavier full snapshot after that

Why

The main startup bottleneck was that desktop launch was doing far more work than the first screen actually needed.

Before this change:

  • backend startup rebuilt orchestration state by replaying the full event history on every launch
  • the initial UI bootstrap fetched the full orchestration snapshot even though the sidebar only needed lightweight project/thread state
  • a couple of startup-only reads were going through the full snapshot path when targeted projection queries were enough

That meant startup time scaled with accumulated history and spent a lot of time doing work that was not needed to show the initial UI.

This keeps the same behavior, but moves the heavy work off the critical path:

  • projections are used for normal bootstrap
  • replay is still there as a safety fallback
  • the full snapshot still gets hydrated after the app becomes usable

Benchmark context:

  • built desktop app, not dev mode
  • same cloned desktop profile for both runs via T3CODE_HOME
  • profile had roughly 699k orchestration events and 73 threads
  • Windows 11
  • 12th Gen Intel(R) Core(TM) i5-12600K @ 3.70 GHz
  • 32 GB RAM @ 3600 MT/s
  • NVMe SSD

Benchmarks on the same production-style desktop profile:

  • main: backend ready in 23.98s
  • this branch: backend ready in 1.08s
  • delta: 22.91s faster (~95.5% reduction)

The biggest startup stall removed by this PR was:

  • main: projection bootstrap -> orchestration engine started = 23.06s
  • this branch: projection bootstrap -> orchestration engine started = 0.16s

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Reduce desktop startup project load time by ~95% with staged snapshot hydration

  • On startup, the UI hydrates from a new lightweight getBootstrapSnapshot (omitting per-thread messages and activities), then schedules a full getSnapshot to backfill the heavyweight collections.
  • The server-side orchestration engine now bootstraps its in-memory read model from the projection snapshot on startup, falling back to full event replay if the snapshot load fails; both paths strip historical thread activities.
  • Two new SQL-backed services power the fast path: ProjectionSnapshotQuery.getBootstrapSnapshot returns a read model without messages/activities, and ProjectionStartupQuery provides lightweight row-count and auto-bootstrap queries used by serverRuntimeStartup.
  • The full getSnapshot and event-replay paths are preserved as fallbacks, so existing behavior is retained if fast-path queries fail.
  • Behavioral Change: the orchestration engine no longer includes historical thread activities in the bootstrapped read model at startup.

Macroscope summarized 49dc85f.

@github-actions github-actions bot added size:XL 500-999 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Apr 1, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9ae143e1-9c6e-4f56-8446-5042b362d3a3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@justsomelegs justsomelegs changed the title Bootstrap orchestration engine from projections perf(desktop): reduce startup project load time by ~95% Apr 1, 2026
@justsomelegs justsomelegs changed the title perf(desktop): reduce startup project load time by ~95% perf(desktop): reduce startup load time by ~95% Apr 1, 2026
@juliusmarminge
Copy link
Copy Markdown
Member

juliusmarminge commented Apr 1, 2026

Fun timing, i just did this stack last night:

PR1: #1646
PR2: #1647
PR3: #1648

@justsomelegs
Copy link
Copy Markdown
Author

justsomelegs commented Apr 1, 2026

Fun timing, i just did this stack last night:

PR1: #1646 PR2: #1647 PR3: #1648

oh sick, probably should have double checked before i submitted. you just move to quick to keep up haha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants