Skip to content

⚡ Bolt: [performance improvement] avoid string[] allocations in GetTaskSearchTokens - #128

Merged
tonythethompson merged 2 commits into
masterfrom
bolt-optimize-task-search-tokens-572405395171916712
Jul 27, 2026
Merged

⚡ Bolt: [performance improvement] avoid string[] allocations in GetTaskSearchTokens#128
tonythethompson merged 2 commits into
masterfrom
bolt-optimize-task-search-tokens-572405395171916712

Conversation

@google-labs-jules

@google-labs-jules google-labs-jules Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

💡 What:
Replaced string.Split with .AsSpan().SplitAny([' ', '\t', '\r', '\n']) in GetTaskSearchTokens inside RootPaletteSearchIndex.cs and WorkspaceRepositorySnapshot.cs. Used a HashSet<string> and passed ReadOnlySpan<char> into helper methods to process tokens and filter out verbs before allocating any strings.

🎯 Why:
The GetTaskSearchTokens method is called repeatedly during search index queries and autocomplete scenarios as the user types. The original string.Split creates a string[] of all separated chunks and allocates an intermediate string for every piece before processing, causing high GC pressure.

📊 Impact:
Eliminates intermediate array and string allocations. Significantly reduces GC pressure during search palette typing operations.

🔬 Measurement:
Compare memory allocations using dotMemory or Visual Studio Profiler while rapidly typing queries with spaces into the root palette or workspace search. The overall Gen 0 collections should be reduced.


PR created automatically by Jules for task 572405395171916712 started by @mta-babel


Summary by cubic

Cut GC allocations in task search tokenization by using span-based splitting and deferring string creation. This reduces stutter while typing in the root palette and workspace search.

  • Refactors
    • Replaced string.Split with query.AsSpan().SplitAny([' ', '\t', '\r', '\n']) in GetTaskSearchTokens for RootPaletteSearchIndex and WorkspaceRepositorySnapshot; process tokens as ReadOnlySpan<char>, trim punctuation, and filter verbs before allocating.
    • Collect distinct tokens in a case-insensitive HashSet<string> and return a string[]; behavior is unchanged.

Written for commit 71f3804. Summary will update on new commits.

Review in cubic

…skSearchTokens

Replaced `string.Split` with `ReadOnlySpan<char>.SplitAny` in `GetTaskSearchTokens` methods (RootPaletteSearchIndex.cs and WorkspaceRepositorySnapshot.cs) to prevent array allocations and intermediate string creations on frequent searches.
@google-labs-jules

Copy link
Copy Markdown
Contributor Author

👋 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.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Task search tokenization

Layer / File(s) Summary
Span tokenization pipeline
QuickShell.Core/Services/RootPaletteSearchIndex.cs, QuickShell.Core/Services/WorkspaceRepositorySnapshot.cs
Task-search queries now use span-based splitting, trimming, verb filtering, and case-insensitive deduplication instead of string splitting and LINQ pipelines.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: tonythethompson

🚥 Pre-merge checks | ✅ 8
✅ Passed checks (8 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Pipeline Stage Enum Ordering ✅ Passed Touched files only rewrite search tokenization; no SessionWorkflowStage enum or comparisons exist in the diff/repo search.
Gpu/Cpu Runtime Boundary ✅ Passed Patch only touches search-tokenization services; no inference/runtime requirement files or diarization code changed, so the GPU/CPU boundary check is not applicable.
Managed Host Restart Safety ✅ Passed PR only changes tokenization in RootPaletteSearchIndex/WorkspaceRepositorySnapshot; none of the managed host/readiness classes or restart/health paths were modified.
Title check ✅ Passed The title matches the main change: reducing allocations in GetTaskSearchTokens.
Description check ✅ Passed The description accurately explains the span-based tokenization and its performance goal.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bolt-optimize-task-search-tokens-572405395171916712
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch bolt-optimize-task-search-tokens-572405395171916712

Comment @coderabbitai help to get the list of available commands.

@coderabbitai
coderabbitai Bot requested a review from tonythethompson July 27, 2026 07:48
@tonythethompson
tonythethompson marked this pull request as ready for review July 27, 2026 08:47
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@tonythethompson
tonythethompson merged commit 0f1d5c1 into master Jul 27, 2026
10 checks passed
@tonythethompson
tonythethompson deleted the bolt-optimize-task-search-tokens-572405395171916712 branch July 27, 2026 08:51
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