Skip to content

perf(startup): reduce desktop first-screen work#934

Merged
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/startup-performance-optimization
May 29, 2026
Merged

perf(startup): reduce desktop first-screen work#934
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/startup-performance-optimization

Conversation

@limityan
Copy link
Copy Markdown
Collaborator

@limityan limityan commented May 29, 2026

Summary

Tracking issue: #949

  • Show the desktop main window from the native startup path, while keeping the frontend show path as a fallback and visibility checkpoint.
  • Move non-critical startup work behind the first visible shell / idle boundary, including IDE, MCP, ACP startup probes and MiniApp catalog refresh.
  • Page session metadata loading so startup fetches only initially visible rows; explicit expand / show-more actions load the next page with loading feedback.
  • Keep workspace and session sections visually expanded by default, so this does not hide existing navigation content to obtain the startup win.
  • Remove the pre-React static logo layer and preserve the Tauri-injected theme background to avoid the black-logo-to-white-logo startup flash.
  • Keep editor/LSP startup lazy and show a first-open loading prompt for the longer editor initialization path.
  • Keep paged session reads on the maintained session index fast path; the page API validates stale entries only for the returned page, while full-list/rebuild paths keep the broader index integrity check.
  • Maintain the session metadata index count incrementally on writes/deletes so the startup fast path does not reintroduce an O(number of sessions) directory scan during normal metadata saves.

Performance Data

Benchmark method: Windows desktop release-fast cold launches, 10 runs per build. The comparison uses the same packaged WebView path (tauri.localhost) for baseline and stage 1. Baseline snapshot: main@9fa991f6; PR head: bf1163d0. The branch is rebased onto gcwing/main@8a93ed70; the newer base commits are i18n contract guardrails and remote-connect owner migration changes, not frontend startup changes.

P50 metric Baseline Stage 1 Delta
Native window show since process start n/a 888.5 ms n/a
main_window_shown 1504.7 ms 1101.8 ms -402.9 ms (-26.8%)
start_application_end 1455.7 ms 1035.6 ms -420.1 ms (-28.9%)
startApplicationDurationMs 614.7 ms 27.7 ms -586.9 ms (-95.5%)
afterRenderDurationMs 584.1 ms 461.4 ms -122.7 ms (-21.0%)
Primary startup API count 15.5 7.0 -8.5 (-54.8%)
Primary startup response bytes 12,891 7,699 -5,192 (-40.3%)
Session metadata loaded 187 27 -160 (-85.6%)
Max session metadata duration 175.1 ms 53.3 ms -121.8 ms (-69.6%)
interactive_shell_ready 1538.9 ms 1628.4 ms +89.4 ms (+5.8%)

Additional notes:

  • mainWindowShownReason was startup-native in all 10 stage-1 runs, with zero frontend fallback shows.
  • The Windows maximize wait is preserved from the existing startup path. A previous no-wait run was excluded from the table because it was not an apples-to-apples packaged WebView run.
  • A focused local metadata benchmark after the final audit fix reports page5_avg_ms=11.550 versus full_list_avg_ms=88.142 for 1000 sessions, or about 7.6x faster for the paged backend path.

Risks and Tradeoffs

  • First visible window time improves by about 403 ms p50, but interactive_shell_ready p50 is still about 89 ms slower. Follow-up work should target React mount/effect cost and shell readiness directly.
  • Deferred ACP / IDE / MCP startup means the first on-demand operation may pay the deferred fetch or startup cost. ACP menu client loading now has an explicit loading state.
  • Session sections remain expanded by default. Only explicit user collapse suppresses metadata fetching, and clicking show more loads the next visible page.
  • Paged session metadata now trusts the maintained index for startup performance and validates stale entries on the returned page. Out-of-band metadata writes outside the current page may require the full-list/rebuild path before they appear.
  • Native startup now reveals a theme-colored shell before React renders. The extra pre-React logo was removed because it caused a double-logo flash.

Verification

  • pnpm run fmt:rs
  • pnpm run check:repo-hygiene
  • pnpm run check:github-config
  • pnpm run i18n:generate
  • pnpm run i18n:audit
  • pnpm run i18n:contract:test
  • pnpm run lint:web
  • pnpm run type-check:web
  • pnpm --dir src/web-ui run test:run
  • cargo test -p bitfun-core list_session_metadata_page -- --nocapture
  • cargo test -p bitfun-core bench_session_metadata_page_vs_full_list -- --ignored --nocapture
  • cargo test -p bitfun-core
  • cargo check --workspace
  • git diff --check
  • git diff --cached --check

@limityan limityan force-pushed the yanzhn/startup-performance-optimization branch from 373373e to b7f3d22 Compare May 29, 2026 09:18
@limityan limityan changed the title perf(startup): defer heavy initialization paths perf(startup): reduce desktop first-screen work May 29, 2026
@limityan limityan marked this pull request as ready for review May 29, 2026 09:18
@limityan limityan force-pushed the yanzhn/startup-performance-optimization branch 3 times, most recently from c3cd14c to 9ad59f8 Compare May 29, 2026 10:00
@limityan limityan force-pushed the yanzhn/startup-performance-optimization branch from 9ad59f8 to bf1163d Compare May 29, 2026 10:28
@limityan limityan merged commit 7a7409d into GCWing:main May 29, 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