陈大猫
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-07-25 15:04:22 +08:00
2026-11-26 18:52:09 +08:00
2026-11-26 23:46:58 +08:00
2026-07-30 10:00:11 +08:00
2026-11-24 10:50:25 +08:00
2026-11-24 10:50:25 +08:00
2026-11-24 10:50:25 +08:00
2026-11-24 10:50:25 +08:00
2026-07-16 16:01:27 +08:00
2026-11-26 23:46:58 +08:00
2026-10-28 23:08:31 -07:00
2026-11-23 18:42:03 +08:00
2026-11-27 10:04:36 +00:00
2026-06-29 20:55:38 +08:00
2026-06-29 20:55:38 +08:00
2026-06-29 10:10:09 +08:00
2026-08-07 08:57:57 +00:00
2026-08-07 08:57:57 +00:00
2026-10-24 10:35:51 +08:00
2026-11-14 23:37:53 +08:00
2026-11-25 21:40:13 +08:00
2026-11-25 21:40:13 +08:00
2026-11-24 10:50:25 +08:00
2026-11-24 10:50:25 +08:00
2026-11-25 22:04:43 +08:00
2026-09-07 17:41:30 +08:00
2026-07-25 15:04:22 +08:00
2026-03-23 09:40:56 +08:00
2026-06-02 20:35:07 +08:00
2026-06-02 20:35:07 +08:00
2026-06-04 18:09:53 +08:00
2026-06-04 18:09:53 +08:00
2026-07-17 14:35:37 +08:00
2026-07-17 14:35:37 +08:00
2026-10-17 21:53:44 +08:00
2026-10-17 22:45:59 +08:00
2026-10-17 22:45:59 +08:00
2026-07-10 23:54:51 +08:00
2026-11-23 18:42:12 +08:00
2026-11-27 10:04:36 +00:00
2026-11-27 10:04:36 +00:00
2026-07-15 15:50:57 +08:00
2026-06-09 18:26:07 +08:00
2026-08-13 13:45:16 +08:00
2026-11-26 17:52:27 +08:00
2026-10-18 16:40:54 +08:00
2026-11-06 00:33:03 +08:00
2026-04-23 13:54:31 +08:00
2026-08-18 16:30:30 +08:00
2026-11-27 00:04:37 +08:00
2026-10-18 19:17:27 +08:00
2026-10-18 19:17:27 +08:00
2026-11-23 18:42:12 +08:00
2026-09-18 14:10:26 +08:00
2026-08-13 13:45:16 +08:00
2026-10-23 12:19:10 +08:00
2026-07-10 20:24:24 +08:00
2026-07-10 20:24:24 +08:00
2026-07-24 22:58:38 +08:00
2026-09-12 11:55:36 +08:00
2026-09-12 11:55:36 +08:00
2026-10-20 01:17:10 +08:00
2026-10-20 01:17:10 +08:00
2026-10-19 21:51:46 +08:00
2026-10-19 21:51:46 +08:00
2026-11-21 16:08:53 +08:00
2026-11-23 15:00:06 +08:00
2026-11-23 15:00:06 +08:00
2026-11-04 04:01:36 -08:00
2026-11-04 04:01:36 -08:00
2026-08-23 22:53:20 +08:00
2026-08-23 22:53:20 +08:00
2026-07-30 15:16:08 +08:00
2026-07-30 15:16:08 +08:00
2026-11-04 02:15:34 -08:00
2026-10-28 23:08:31 -07:00
2026-10-26 15:07:38 +00:00
2026-10-26 15:07:38 +00:00
2026-11-07 07:10:08 +08:00
2026-10-28 23:08:31 -07:00
2026-10-27 09:03:40 +00:00
2026-07-24 22:58:38 +08:00
2026-06-02 20:35:07 +08:00
2026-06-02 20:35:07 +08:00
2026-07-17 14:35:37 +08:00
2026-07-17 14:35:37 +08:00
2026-11-23 11:00:14 +08:00
2026-11-23 11:00:14 +08:00
2026-10-24 12:56:58 +08:00
2026-10-18 14:01:26 +08:00
2026-08-31 19:27:41 +08:00
2026-10-19 16:05:29 +08:00
2026-10-19 16:05:29 +08:00
2026-11-26 18:52:09 +08:00
2026-06-11 04:19:21 +08:00
2026-09-29 17:34:00 +08:00
2026-09-30 00:38:50 +08:00
2026-09-29 17:34:00 +08:00
2026-09-12 11:11:07 +08:00
2026-07-25 12:10:47 +08:00
2026-11-21 16:08:53 +08:00
2026-11-23 11:00:14 +08:00
2026-10-27 01:59:11 +08:00
2026-08-31 11:44:08 +08:00
2026-06-30 18:03:02 +08:00
2026-10-18 13:20:46 +08:00
2026-07-28 11:35:17 +08:00
2026-03-23 09:40:56 +08:00
2026-07-04 13:34:04 +08:00
2026-09-12 11:55:36 +08:00
2026-10-19 21:51:46 +08:00
2026-09-05 13:13:56 +08:00
2026-08-15 01:13:19 +08:00
2026-08-23 22:47:30 +08:00
2026-07-25 08:39:59 +08:00