bruits / bruits/zoecss

Cache `CompiledConfig` across runs in watch mode

Open
#28 0 comments 0 reactions 0 assignees View on GitHub
crt:cli crt:config crt:core enhancement performance
Dominant language
Rust
Stars
10
Forks
0
PR merge metrics
No merged PRs in 30d

Description

### 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` 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

1. Extract config construction into a function returning a content hash + `CompiledConfig`.
2. On each watch iteration, rebuild config inputs, compare hash. If unchanged, reuse cached `Arc`.
3. Expected improvement: pipeline per rebuild drops from ~30 ms to ~0.2 ms (~150x).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating CompiledConfig::compile and the pipeline iteration that would support watch mode; no specific files or tests are named. Trace how built-in and future user configuration inputs are constructed, then verify that unchanged inputs reuse the in-memory compiled configuration while changed inputs trigger recompilation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
performance, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.