Skip to content

⚡ Bolt: [SearchEngine] Optimize RouteMatcher regex precomputation with single-pass string parsing#242

Merged
AhmmedSamier merged 1 commit intomasterfrom
route-matcher-perf-8373083886981394089
Mar 1, 2026
Merged

⚡ Bolt: [SearchEngine] Optimize RouteMatcher regex precomputation with single-pass string parsing#242
AhmmedSamier merged 1 commit intomasterfrom
route-matcher-perf-8373083886981394089

Conversation

@AhmmedSamier
Copy link
Owner

💡 What: Replaced 5 consecutive replaceAll regex operations in RouteMatcher.getOrCompileCache with a single-pass string parsing loop.

🎯 Why: The RouteMatcher converts ASP.NET route templates to standard regexes to search for Endpoints. Using multiple .replaceAll operations on string inputs causes multiple intermediate string allocations and regex execution overhead, acting as a bottleneck when calculating paths for search items or index generation.

📊 Impact: Approximately 4.7x faster template to regex conversion (benchmarked at ~187ms vs ~39ms for 100k iterations). This reduces CPU and memory overhead when scanning and matching endpoint strings.

🔬 Measurement: Run bun test src/core/route-matcher.test.ts src/core/route-matcher-regression.test.ts within the language-server directory to verify functionality remains unchanged. You can also benchmark with perf_hooks loop over stringApproach vs original regexApproach.


PR created automatically by Jules for task 8373083886981394089 started by @AhmmedSamier

…ing in RouteMatcher

Replaced 5 consecutive `replaceAll` regex operations in `RouteMatcher.getOrCompileCache` with a single-pass string parsing and substitution loop. Benchmarking showed an improvement of ~4.7x for precomputing ASP.NET route templates. This optimization reduces string allocations and regex compilations during indexing/search.

Co-authored-by: AhmmedSamier <17784876+AhmmedSamier@users.noreply.github.com>
@google-labs-jules
Copy link
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.

@AhmmedSamier AhmmedSamier merged commit e691dcf into master Mar 1, 2026
1 check passed
@AhmmedSamier AhmmedSamier deleted the route-matcher-perf-8373083886981394089 branch March 1, 2026 02:41
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