Skip to content

follow-up: memoize compiled include/exclude globs per build #1000

@carlos-alm

Description

@carlos-alm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    follow-upDeferred work from PR reviews that needs tracking

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions