Skip to content

perf(startup): bootstrap workspace startup state - #1261

Merged
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/perf-startup-bootstrap-snapshot
Jun 18, 2026
Merged

perf(startup): bootstrap workspace startup state#1261
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/perf-startup-bootstrap-snapshot

Conversation

@limityan

@limityan limityan commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Prepare the workspace startup state snapshot during desktop startup and inject it into the WebView bootstrap script so the first window can avoid the startup initializeWorkspaceStartupState IPC waterfall.
  • Keep the original frontend command as the fallback path when the bootstrap snapshot is missing, invalid, cannot be serialized, or exceeds the 64KB bootstrap cap.
  • Add bounded E2E-only resource timing data to startup performance reports for future cold-start bottleneck analysis without adding runtime log noise.

Refs #949

Performance data

Test profile: release-fast, 5 cold-start samples. Baseline is latest gcwing/main at d8f2d2e2; modified result is this PR at 4e1f4e27.

Scenario / metric Before After Delta
Cold start: shell interactive median 450.1 ms 442.6 ms -7.5 ms
Cold start: first script eval median 223.9 ms 223.5 ms -0.4 ms
Cold start: window shown to interactive median 187.5 ms 186.2 ms -1.3 ms
Workspace startup state available to frontend 118.6 ms 7.4 ms -111.2 ms
Workspace startup state step 114.8 ms 4.6 ms -110.2 ms
initializeWorkspaceStartupState frontend IPC wait 113.7 ms not on first-window path removed from first-window path
Native bootstrap snapshot preparation n/a 1.0 ms +1.0 ms before WebView creation
Native create_main_window median 497 ms 491 ms -6 ms
Native WebView build median 458 ms 450 ms -8 ms

Long-session interaction guard after the change, using the focused release-fast core profile:

Guard scenario Result
First open latest text visible 183.3 ms
First open full history ready 251.3 ms
Rapid switch latest text visible 151.0 ms
Rapid switch latest usable 187.8 ms
First scroll latest text visible 174.4 ms
Resize latest text visible 154.9 ms
Blank surface events across guard samples 0

Risk and compatibility

  • This moves existing workspace startup state preparation before the main WebView is created. The measured native preparation median is 1.0 ms; the 64KB cap prevents large workspace lists from being injected into the bootstrap script. Oversized or failed snapshots fall back to the existing IPC command.
  • The implementation reuses the existing startup-state collection path instead of introducing a second data model, so workspace cleanup/current workspace/recent workspace/legacy remote snapshot semantics stay aligned with the command path.
  • Remote workspace data is not transformed differently by this PR. The frontend maps the injected snapshot through the same mapWorkspaceStartupStateSnapshot logic used by the command response.
  • Resource timing is collected only inside the E2E startup report and is bounded to 40 sampled entries per list. It does not add product runtime logging.

Validation

  • pnpm --dir src/web-ui run test:run src/shared/types/global-state.test.ts src/app/startup/startupPerformanceContract.test.ts
  • pnpm run type-check:web
  • cargo check -p bitfun-desktop
  • node tests/e2e/scripts/perf-coverage-contract.test.mjs
  • git diff --check gcwing/main..HEAD
  • pnpm run e2e:test:perf:startup-stability:release-fast
  • pnpm run e2e:test:perf:long-session-interactions:release-fast -- --profile core

@limityan
limityan merged commit 665ae9b into GCWing:main Jun 18, 2026
4 checks passed
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