陈大猫
3998add458
perf(memory): Phase 3 deep business-code memory optimization across main, renderer, and active terminals
Completes exhaustive business-code memory optimization stacked on Phase 1-2 (#4476),
reaching the business-code floor before Electron-level optimization:
Round 1 - Renderer Cold Start & Preload Minification:
- Enable esbuild minification in scripts/build-preload.mjs (368 KB -> 103 KB, -72%)
- Remove eager requestIdleCallback TerminalLayer mount in AppMounts.tsx
- Add compact capability lookup maps to toolNameIndex.json so permissionGrants drops
static cattyToolSpecs.json (126 KB) from startup
- Lazy-load pinyin-pro (447 KB) on first CJK text via usePinyinMatcherVersion hook
(synchronous createRequire in Node/test mode, zero top-level await)
Round 2 & 3 - Main Process & terminalWorker Zero-Dead-Weight Startup:
- Lazy-load all third-party npm packages on startup (0 npm packages loaded at boot;
require.cache 657 -> 234 modules, -64.4%; main heapTotal 54 -> 23.3 MiB):
ajv/ajv-formats/plugin-contract schema, electron-updater, jsqr, ws, webmDurationPatch,
terminalPerformanceDiagnostics, ssh2, ssh2-sftp-client, iconv-lite, zmodem.js,
node-pty/serialport (Electron-gated so Node Module._load mocks stay 100% intact),
11 AI SDK drivers, CodexAppServerRuntime, codebuddy, aiPrivacyService, re2js,
external MCP setup, 17 capability modules, and 7 systemManager/*Ops modules
- Clean up windowManager readiness/unhealthy maps on BrowserWindow closed
Round 4 - Renderer Startup Bundle Decomposition:
- Lazy-load HostDetailsPanel (134 KB), GroupDetailsPanel (29 KB), KnownHostsManager,
QuickConnectWizard, SerialConnectModal, Serial/LocalHostDetailsPanel,
ImportVaultDialog, VaultImportProgressPanel, domain/vaultImport (55 KB),
TerminalHostTreeSidebar (35 KB), ToolCall (26 KB), vaultAgentBridgeClient (47 KB)
- Tree-shake package.json in cloudSync (-32 KB from useUpdateCheck)
- Main App-*.js chunk: 1,550 KB -> 714.6 KB (-53.9%)
Round 5 - Active Multi-Terminal Memory Optimization:
- Remove unconditional requestIdleCallback preload of AIChatSidePanel (~1.5 MB JS /
vendor-ai + globalAgentRuntime + tool specs) in TerminalLayerSupport.tsx
- Remove eager 67-spec Fig autocomplete preloading (1.25 MB raw JS imported into
main-process ESM cache + renderer specCache) in useTerminalAutocomplete.ts; specs
load on demand via completionEngine.ts loadSpec()
Verified Clean-VM Benchmarks (0-host idle, 3x median, vs Blank Electron 97.6 MiB PrivDirty):
- Total Private Dirty RAM: 324.8 -> 234.6 (Phase 1-2) -> 184.2 MiB (-43.3%, 61.9% of
all Netcatty overhead above Blank Electron eliminated)
- Renderer v8/main/heap: 24.84 -> 9.35 MiB (-62.4%); jsHeapUsedMB: 35.98 -> 12.76 MiB
(only +3.22 MiB above about:blank)
- Active 5 local terminals + 1,000-line ANSI burst: Peak PrivDirty -25.6 MiB
(395.9 -> 370.3 MiB), main PrivDirty -11.3 MiB, renderer PrivDirty -14.2 MiB,
zero xterm/canvas/listener/per-session heap leaks across 2x5 open/close cycles
2026-11-27 10:04:36 +00:00
..
2026-10-27 13:39:03 +00:00
2026-10-28 23:08:31 -07:00
2026-10-26 14:46:30 +00:00
2026-10-28 16:32:41 +08:00
2026-11-23 18:42:03 +08:00
2026-11-26 17:52:27 +08:00
2026-11-26 17:52:27 +08:00
2026-10-27 11:48:35 +00:00
2026-10-26 05:26:25 +00:00
2026-11-23 18:42:03 +08:00
2026-11-23 18:42:03 +08:00
2026-11-26 23:26:18 +08:00
2026-11-26 17:52:27 +08:00
2026-11-26 17:52:27 +08:00
2026-10-27 02:28:08 +00:00
2026-11-26 23:26:18 +08:00
2026-11-26 23:26:18 +08:00
2026-10-28 23:08:31 -07:00
2026-10-26 03:25:40 +00:00
2026-10-26 13:15:52 +00:00
2026-10-26 09:13:45 +00:00
2026-07-29 04:35:04 +08:00
2026-07-26 00:39:28 +08:00
2026-11-26 17:52:27 +08:00
2026-07-20 12:39:29 +08:00
2026-07-20 12:39:29 +08:00
2026-11-27 10:04:36 +00:00
2026-11-26 23:26:18 +08:00
2026-11-26 17:52:27 +08:00
2026-11-26 23:42:04 +08:00
2026-07-20 12:39:29 +08:00
2026-11-23 11:00:14 +08:00
2026-10-28 23:08:31 -07:00
2026-07-19 18:04:01 +08:00
2026-10-26 03:10:48 +00:00
2026-10-26 03:10:48 +00:00
2026-10-27 02:28:08 +00:00
2026-10-26 14:37:25 +00:00
2026-11-04 02:33:16 -08:00
2026-10-28 23:08:31 -07:00
2026-11-27 10:04:36 +00:00
2026-08-05 18:43:10 +08:00
2026-11-23 11:00:14 +08:00
2026-10-27 08:49:54 +00:00
2026-11-07 07:10:08 +08:00
2026-11-07 07:10:08 +08:00
2026-10-28 23:08:31 -07:00
2026-11-26 23:26:18 +08:00
2026-11-26 23:26:18 +08:00
2026-11-26 17:52:27 +08:00
2026-11-23 18:42:03 +08:00
2026-11-23 18:42:03 +08:00
2026-11-23 18:42:03 +08:00
2026-11-26 23:26:18 +08:00
2026-11-26 17:52:27 +08:00
2026-10-27 02:28:08 +00:00
2026-11-26 23:26:18 +08:00
2026-11-26 17:52:27 +08:00
2026-10-28 23:08:31 -07:00
2026-11-26 17:52:27 +08:00
2026-11-26 17:52:27 +08:00
2026-11-26 23:42:04 +08:00
2026-10-28 23:08:31 -07:00
2026-11-26 17:52:27 +08:00
2026-07-19 08:22:17 +08:00
2026-07-19 18:04:01 +08:00
2026-07-20 12:39:29 +08:00
2026-07-20 12:39:29 +08:00
2026-10-26 07:03:14 +00:00
2026-10-26 15:00:54 +00:00
2026-10-28 16:32:41 +08:00
2026-10-26 13:15:52 +00:00
2026-07-19 08:22:17 +08:00
2026-07-19 08:22:17 +08:00
2026-10-26 06:01:13 +00:00
2026-10-26 06:01:13 +00:00
2026-11-23 11:00:14 +08:00
2026-10-26 07:03:14 +00:00
2026-11-26 23:42:04 +08:00
2026-11-26 23:42:04 +08:00
2026-10-28 23:08:31 -07:00
2026-07-19 08:22:17 +08:00
2026-07-19 08:22:17 +08:00
2026-10-27 08:49:54 +00:00
2026-10-27 02:28:08 +00:00
2026-10-27 03:17:53 +00:00
2026-10-27 02:28:08 +00:00
2026-10-27 02:28:08 +00:00
2026-11-26 17:52:27 +08:00
2026-10-28 23:08:31 -07:00
2026-11-27 10:04:36 +00:00
2026-11-22 17:33:03 +08:00
2026-10-26 15:00:54 +00:00
2026-10-26 15:00:54 +00:00
2026-10-26 15:00:54 +00:00
2026-10-26 15:00:54 +00:00
2026-10-26 15:00:54 +00:00
2026-10-26 15:00:54 +00:00
2026-11-07 07:10:08 +08:00
2026-10-26 07:18:21 +00:00
2026-11-26 23:42:04 +08:00
2026-10-28 23:08:31 -07:00
2026-10-26 17:03:15 +00:00
2026-10-27 12:23:21 +00:00
2026-08-05 18:43:10 +08:00
2026-10-26 14:37:25 +00:00
2026-10-26 14:37:25 +00:00
2026-11-26 17:52:27 +08:00
2026-07-19 18:04:01 +08:00
2026-10-28 16:32:41 +08:00
2026-10-28 16:32:41 +08:00
2026-10-28 16:32:41 +08:00
2026-10-28 16:32:41 +08:00
2026-11-27 10:04:36 +00:00
2026-07-20 12:39:29 +08:00
2026-07-26 00:39:28 +08:00
2026-07-23 09:42:47 +08:00
2026-10-27 12:23:20 +00:00
2026-10-26 18:34:59 +00:00
2026-10-26 14:26:41 +00:00
2026-07-19 18:04:01 +08:00
2026-11-26 17:52:27 +08:00
2026-11-26 17:52:27 +08:00
2026-11-26 17:52:27 +08:00
2026-11-26 17:52:27 +08:00
2026-10-28 23:08:31 -07:00
2026-07-29 03:33:00 +08:00
2026-07-29 03:33:00 +08:00
2026-10-26 13:15:52 +00:00
2026-10-26 13:15:52 +00:00
2026-10-26 13:34:59 +00:00
2026-11-07 07:10:08 +08:00
2026-10-26 13:15:52 +00:00
2026-10-26 14:37:25 +00:00
2026-10-26 13:15:52 +00:00
2026-10-26 13:15:52 +00:00
2026-10-28 23:08:31 -07:00
2026-10-28 23:08:31 -07:00
2026-10-26 17:03:15 +00:00
2026-10-26 17:29:55 +00:00
2026-10-27 02:28:08 +00:00
2026-07-29 03:33:00 +08:00
2026-07-23 09:42:47 +08:00
2026-07-23 09:42:47 +08:00
2026-07-23 09:42:47 +08:00
2026-07-23 09:42:47 +08:00
2026-11-23 11:00:14 +08:00
2026-07-21 10:44:36 +08:00
2026-11-25 22:03:23 +08:00
2026-11-25 22:03:23 +08:00
2026-10-27 02:28:08 +00:00
2026-07-20 12:39:29 +08:00
2026-07-20 12:39:29 +08:00
2026-10-26 11:46:08 +00:00
2026-10-26 12:07:46 +00:00
2026-10-26 23:04:54 +08:00
2026-07-23 09:42:47 +08:00
2026-11-23 11:00:14 +08:00
2026-11-26 23:42:04 +08:00
2026-11-26 23:42:04 +08:00
2026-10-28 23:08:31 -07:00