⚡ Bolt: Optimize KnowledgeGraph search and highlight performance#285
⚡ Bolt: Optimize KnowledgeGraph search and highlight performance#285hadsern wants to merge 1 commit into
Conversation
* 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>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What:
Optimized the
KnowledgeGraph.tsxcomponent by pre-indexing node data into a Map and a pre-lowercased array during theuseMemocomputation. 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:$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.
Reduces search and highlight overhead from
🔬 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