Problem
CompiledConfig::compile() takes ~30 ms and accounts for ~99% of the full pipeline. In a future watch mode, recompiling on every file change is wasteful since the config rarely changes.
Proposed solution
Cache the CompiledConfig in memory and skip recompilation when the config inputs haven't changed.
Requirements
- In-memory only —
CompiledConfig contains Regex, RegexSet, and fn pointers (Rule::Dynamic). Not serializable to disk.
- Invalidation trigger — recompile only when config source changes:
- Built-in presets: static, never change within a binary run. No invalidation needed.
- Future user config file (TOML/etc.): invalidate on file mtime/content hash change.
- Storage —
Arc<CompiledConfig> shared across iterations. Replace on invalidation.
- Scope — this is a building block for a watch mode / dev server, not useful in the current one-shot CLI.
Suggested approach
- Extract config construction into a function returning a content hash +
CompiledConfig.
- On each watch iteration, rebuild config inputs, compare hash. If unchanged, reuse cached
Arc<CompiledConfig>.
- Expected improvement: pipeline per rebuild drops from ~30 ms to ~0.2 ms (~150x).
Problem
CompiledConfig::compile()takes ~30 ms and accounts for ~99% of the full pipeline. In a future watch mode, recompiling on every file change is wasteful since the config rarely changes.Proposed solution
Cache the
CompiledConfigin memory and skip recompilation when the config inputs haven't changed.Requirements
CompiledConfigcontainsRegex,RegexSet, andfnpointers (Rule::Dynamic). Not serializable to disk.Arc<CompiledConfig>shared across iterations. Replace on invalidation.Suggested approach
CompiledConfig.Arc<CompiledConfig>.