Skip to content

⚡ Bolt: [performance improvement] Cache compiled regex filters in buildIgnoreFilter#85

Draft
raccioly wants to merge 1 commit intomainfrom
bolt-optimize-ignore-filter-7056376380095519862
Draft

⚡ Bolt: [performance improvement] Cache compiled regex filters in buildIgnoreFilter#85
raccioly wants to merge 1 commit intomainfrom
bolt-optimize-ignore-filter-7056376380095519862

Conversation

@raccioly
Copy link
Copy Markdown
Owner

@raccioly raccioly commented May 5, 2026

💡 What

Implemented an internal filterCache (Map) within buildIgnoreFilter in cli/shared-ignore.mjs. This cache uses the JSON-stringified patterns array as the cache key to store and reuse the compiled regex filter functions. Added a corresponding entry to the Bolt journal (.jules/bolt.md).

🎯 Why

During recursive directory scans, functions like shouldIgnore continually re-evaluate the same global and validator-specific configuration patterns. Previously, this caused the regexes to be re-compiled for every check, leading to redundant computation and performance bottlenecks in large codebases.

📊 Impact

Reduces regex compilation overhead to O(1) per unique pattern array, significantly speeding up recursive file traversals and the overall execution time of the CLI, especially in large repositories with extensive ignore configurations.

🔬 Measurement

Run pnpm test to ensure all 61 tests pass. Profile the docguard guard command on a large directory structure; you will observe a noticeable reduction in CPU time spent inside globToRegex and buildIgnoreFilter.


PR created automatically by Jules for task 7056376380095519862 started by @raccioly

Optimized `buildIgnoreFilter` in `cli/shared-ignore.mjs` to cache compiled regex filters using a `Map`. This prevents redundant regex compilation overhead during recursive directory scans. Added a critical learning to `.jules/bolt.md`.

Co-authored-by: raccioly <63126795+raccioly@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant