Context
Surfaced in review of PR #994 (fix(config): honor include/exclude globs in file collection).
Claude reviewer noted:
Performance: Glob compilation happens on every collectFiles call in non-incremental path. Consider memoizing compiled regexes in config loading.
Current state
compileGlobs in src/shared/globs.ts is called once per buildGraph invocation (entry via collectFiles top-level, then passed through recursion). Cost is bounded — not per-file.
- On the Rust side,
build_glob_set is likewise called once per collect_files.
- Impact: low — but a larger build invoked in a long-running host (MCP server, watch mode) recompiles on every rebuild.
Proposal
Memoize compiled RegExp/GlobSet at config-load time so they travel with the loaded config instead of being recompiled on each graph build. Invalidate when the config file changes.
Out of scope of #994
PR #994 is a bug-fix for the include/exclude filters being entirely unwired. Memoization is a pure performance optimization with no behavior change.
Context
Surfaced in review of PR #994 (fix(config): honor include/exclude globs in file collection).
Claude reviewer noted:
Current state
compileGlobsinsrc/shared/globs.tsis called once perbuildGraphinvocation (entry viacollectFilestop-level, then passed through recursion). Cost is bounded — not per-file.build_glob_setis likewise called once percollect_files.Proposal
Memoize compiled
RegExp/GlobSetat config-load time so they travel with the loaded config instead of being recompiled on each graph build. Invalidate when the config file changes.Out of scope of #994
PR #994 is a bug-fix for the include/exclude filters being entirely unwired. Memoization is a pure performance optimization with no behavior change.