Skip to content

⚡ Bolt: Optimize KnowledgeGraph search and highlight performance#285

Open
hadsern wants to merge 1 commit into
v2-foundationfrom
bolt-optimize-knowledge-graph-8669985841118444466
Open

⚡ Bolt: Optimize KnowledgeGraph search and highlight performance#285
hadsern wants to merge 1 commit into
v2-foundationfrom
bolt-optimize-knowledge-graph-8669985841118444466

Conversation

@hadsern

@hadsern hadsern commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator

💡 What:
Optimized the KnowledgeGraph.tsx component by pre-indexing node data into a Map and a pre-lowercased array during the useMemo computation. This replaces redundant O(N) string conversions (.toLowerCase()) and array traversals (.find() and .filter()) inside the component's render and event handler loops.

🎯 Why:
Typing in the search bar, changing focus, or rendering suggestions was triggering expensive case-insensitive array lookups on every keystroke. For large graphs, these repeated string allocations and traversals can cause noticeable UI thread blocking and input lag.

📊 Impact:
Reduces search and highlight overhead from $O(N)$ with multiple string conversions to $O(1)$ for exact matches, and a much faster, allocation-free $O(N)$ for partial text matches. Significantly improves input responsiveness in the Knowledge Graph search bar.

🔬 Measurement:
Type rapidly in the KnowledgeGraph filter/search input. The keystroke latency and UI unresponsiveness should be noticeably reduced. Reviewing CPU profiling will show significantly less time spent in garbage collection and string functions.


PR created automatically by Jules for task 8669985841118444466 started by @hadsern

* Pre-index node data in `useMemo` into a Map for O(1) exact lookups
* Create a pre-lowercased search index array for faster O(N) case-insensitive search
* Reduce UI thread blocking during high-frequency events like typing in the search bar or hovering/focusing nodes
* Document optimization learning in `.jules/bolt.md`

Co-authored-by: hadsern <5723837+hadsern@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 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