perf(startup): defer editor and AI initialization#971
Merged
Conversation
de70290 to
e1895e6
Compare
c89dfd3 to
ea1ac6a
Compare
ea1ac6a to
20d6a23
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Decision Status
This PR remains draft under #949, but the editor first-open regression called out in the previous PR description has now been mitigated with measured release-fast data.
Current data is positive for the target startup path and for the measured editor-heavy first-open paths. Remaining merge risk is mostly measurement rigor: the branch was rebased onto latest
gcwing/main@18aa2df4, but the comparison baseline below is the existing #949 baseline (gcwing/main@978e079f) rather than a freshly rerun latest-main strict A/B baseline.Refs #949
Summary
main.tsxintoMonacoInitManager, so editor runtime work starts only when the editor is initialized.CodeEditor,DiffEditor,MarkdownEditor,ImageViewer,GitDiffEditor) fromFlexiblePanelwith a lightweight fallback.bitfun:interactive-shell-readyinstead of the earlier main-window signal, with a 10s watchdog fallback.AppAI auto-initialization and model-config subscription; AI initialization remains on explicit/on-demand service paths.Loading workspace...below the logo only after 1800ms if workspace loading is still active, avoiding the short loading-text flash during normal startup.Measurement Method
release-fast.20d6a235, rebased ongcwing/main@18aa2df4.gcwing/main@978e079ffrom perf(startup): continue reducing desktop startup and interactive shell readiness time #949's existing measurement set.tests/e2e/specs/performance/startup-session-perf.spec.ts.tests/e2e/specs/performance/editor-first-open-perf.spec.ts.Runtime Results
Cold Startup, p50
first_script_evalmain_window_showninteractive_shell_readynon_critical_init_doneStartup target result: positive on the measured release-fast head data.
First Open Of Long Historical Session, p50
Long-session result: neutral to slightly positive, with the remaining regressions under 2 ms p50 in this run.
First Editor-Heavy Interaction, p50
Editor result: the previous first-use regression is mitigated. Compared with the previous PR measurement, code-editor p50 drops by 296.3 ms and Git-diff p50 drops by 243.2 ms. Compared with the continuity baseline, code-editor p50 improves by 176.7 ms (-46.0%) and Git-diff p50 improves by 127.4 ms (-32.0%) in the explicit-warmup path.
Background Editor Warmup Cost
This work is deliberately scheduled after splash exit and split across idle slices. It still consumes post-startup idle time and is not free.
Bundle / Parse-Pressure Evidence
Measured earlier with
pnpm --dir src/web-ui run buildon this PR line.gcwing/main@978e079fClick to toggle color options,editor.action.showHover)useAIInitialization)Net entry JS reduction: 4,004,248 bytes / 48.25%.
Risks / Functional Impact
bitfun:interactive-shell-readyreduces startup pressure but can delay tool/context-menu availability if the readiness event is late or missed; the watchdog caps this at 10s.Current Decision
Do not merge solely on bundle-size or architecture arguments. With the current release-fast data, this PR now has a measured user-facing performance result:
The remaining blocker is whether we require a fresh latest-main strict A/B run before marking the draft ready.
Verification
pnpm --dir src/web-ui run test:run src/tools/editor/services/MonacoStartupWarmup.test.ts src/app/startup/startupPerformanceContract.test.ts src/app/components/SplashScreen/SplashScreen.test.tsx src/infrastructure/theme/integrations/MonacoThemeSync.test.ts src/shared/utils/startupTaskScheduling.test.ts src/infrastructure/services/api/aiService.test.tspnpm run type-check:webpnpm run i18n:auditpnpm run check:repo-hygienepnpm run desktop:build:release-fastgit diff --check gcwing/main...HEADBITFUN_E2E_APP_MODE=release-fast pnpm --dir tests/e2e run test:perfrepeated 5 timesBITFUN_E2E_EDITOR_SCENARIO=code-editor pnpm --dir tests/e2e exec wdio run ./config/wdio.conf.ts --spec ./specs/performance/editor-first-open-perf.spec.tsrepeated 5 times without explicit warmup wait and 5 times with explicit warmup waitBITFUN_E2E_EDITOR_SCENARIO=git-diff pnpm --dir tests/e2e exec wdio run ./config/wdio.conf.ts --spec ./specs/performance/editor-first-open-perf.spec.tsrepeated 5 times without explicit warmup wait and 10 times with explicit warmup wait