Repository navigation
perf(electron): load the MCP SDK, fastify and the updater when first used - #13633
yuxi-liu-wired wants to merge 1 commit into
Conversation
|
Measured this optimization with ablations against upstream, using the same shared warm profile, Xvfb, hyperfine, 20 measured runs per build and CPU settings fixed at 100% with turbo enabled. Whole-command mean ± standard deviation:
The three changes together reproduce the full fork's startup performance. Launch-to-real-home for the three-change build: 2.077 ± 0.017 seconds versus upstream 2.621 ± 0.025 seconds. Code-block first use was checked using real keyboard events: three backticks mount CodeMirror; typing and selection work. Ablation base: 22a29b3. Combined patch: d462a777b0. Raw benchmark JSON and per-run stages are retained locally at All three optimizations are already included in published fork-nightly commit 1771ba4. The lazy editor includes the module-registration completion fix. |
7e3552b to
d891597
Compare
28f3ac9 to
008ae5d
Compare
…used The Electron main process loads the MCP SDK and zod, fastify and electron-updater before it creates the main window, through the top-level requires of `electron.mcp-server`, `electron.server`, `electron.updater` and `electron.handler`. In a CPU profile of a desktop app open, those requires took about 210 ms (MCP SDK and `zod/v3`), 115 ms (`electron-updater`) and 65 ms (`fastify`, `@fastify/cors`) of the main process's time before the window. None is needed for the window: the API server and MCP are off by default, and the updater is first used after the page loads. - `electron.mcp-server` requires the SDK modules and zod on first use (the first `/mcp` initialize, or the first MCP server it creates); the tool definitions are built per server from the loaded zod. - `electron.server/start!` requires fastify and `@fastify/cors` when the API server starts. - `electron.updater` requires electron-updater when it is used, and `setup-updater!` sets the updater up when the main window's page has finished loading (its teardown is returned as before); `electron.handler`'s `:quitAndInstall` requires it there too. Checked in a desktop build: with the API server and MCP turned on, an MCP `initialize` over HTTP gets a session and `tools/list` returns listPages, getPage, upsertNodes, searchBlocks, listTags and listProperties; in a CPU profile of the main process before the window, none of the MCP SDK, electron-updater or fastify is loaded.
008ae5d to
094e03d
Compare
|
Combined into #13872 with the other PRs of this theme, to keep the number of open PRs down; the commits are unchanged there. |
The Electron main process loads the MCP SDK and zod, fastify and electron-updater before it creates the main window, through the top-level requires of
electron.mcp-server,electron.server,electron.updaterandelectron.handler. In a CPU profile of a desktop app open, those requires took about 210 ms (MCP SDK andzod/v3), 115 ms (electron-updater) and 65 ms (fastify,@fastify/cors) of the main process's time before the window. None is needed for the window: the API server and MCP are off by default, and the updater is first used after the page loads.electron.mcp-serverrequires the SDK modules and zod on first use (the first/mcpinitialize, or the first MCP server it creates); the tool definitions are built per server from the loaded zod.electron.server/start!requires fastify and@fastify/corswhen the API server starts.electron.updaterrequires electron-updater when it is used, andsetup-updater!sets the updater up when the main window's page has finished loading (its teardown is returned as before);electron.handler's:quitAndInstallrequires it there too.Checked in a desktop build: with the API server and MCP turned on, an MCP
initializeover HTTP gets a session andtools/listreturns listPages, getPage, upsertNodes, searchBlocks, listTags and listProperties; in a CPU profile of the main process before the window, none of the MCP SDK, electron-updater or fastify is loaded.