Skip to content

[P1] Fire-and-forget prefetch for startup operations / 启动操作火忘式预取 #3222

@doudouOUC

Description

@doudouOUC

Priority: P1
Category: performance, cli
Parent: #3011
Depends on: Startup profiler, Lazy tool registration

Problem / 问题

gemini.tsx main() is fully sequential. Operations like extension cache refresh, MCP connection, telemetry init, and update check block REPL rendering even though their results are not needed for the first user interaction.

main() 完全串行。扩展缓存刷新、MCP 连接、遥测初始化、更新检查等操作阻塞 REPL 渲染,但首次交互并不需要它们。

Proposed Solution / 方案

Categorize startup operations by criticality:

Must await (critical path):

  • loadSettings(), parseArguments(), loadCliConfig()
  • performInitialAuth()
  • Core config initialization

Fire-and-forget (defer to after render):

  • extensionManager.refreshCache()
  • MCP server connections
  • Telemetry initialization
  • Update check
  • Git repository detection
  • IDE client connection (if not in IDE mode)

Implementation pattern:

// Critical path — await
await performInitialAuth();

// Fire-and-forget — don't await
void connectMcpServers();
void initTelemetry();
void checkForUpdates();

Reference: Claude Code startDeferredPrefetches() — same pattern, all prefetches run after root.render().

Acceptance Criteria / 验收标准

  • REPL renders before MCP connections, telemetry init, and update check complete
  • Critical path (auth, config) still awaited before render
  • All deferred operations complete within 5s of render
  • No user-visible regressions in MCP tool availability

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions