mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-10 06:23:28 +09:00
memory-tools.ts and hooks-tools.ts had 5 + 1 sites that did
\`await import('fs')\` / \`await import('os')\` inside handler bodies even
though the same exports were already imported statically at the top of
the file. Each await-import on a cached module adds:
- one async microtask roundtrip (~2µs per call on this host)
- an async boundary that propagates up the call chain
- a TypeScript erasure that hides which module the binding came from
Microbench (50k iters, M2 Mac):
dynamic await import('fs')+import('os'): 107.47 ms (2.15 µs/iter)
static reference: 0.25 ms (0.005 µs/iter)
speedup: 423x
Sites changed:
memory-tools.ts:
- memory_import_claude: 1× await import('os') + 2× await import('fs')
- memory_bridge_status: 1× await import('os') + 1× await import('fs')
Pulled readdirSync + homedir into the static import block at top.
Also removed dead line `const projects = readFileSync;` (was a leftover
no-op assignment with a misleading comment).
hooks-tools.ts:
- file-scanner handler: 1× await import('node:fs') for readdirSync+
statSync that were already imported at the top.
Verified:
tsc --noEmit clean
__tests__/mcp-tools-deep + memory-ruvector-deep: 252/252 passing.