⚡ Bolt: Optimize graph edge iteration for PageRank and HITS#97
⚡ Bolt: Optimize graph edge iteration for PageRank and HITS#97saurabhsharma2u wants to merge 1 commit intomainfrom
Conversation
|
👋 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: Added a memory-efficient
forEachEdgeiterator to theGraphclass and updated thePageRankServiceandHITSServicealgorithms to use it instead of callinggraph.getEdges().🎯 Why: Calling
graph.getEdges()inside these algorithm setups was previously mapping every single edge in thegraph.edgesMap to a new{ source, target, weight }object array. This massive spike in array object allocations immediately before memory-heavy typed array allocations led to severe Garbage Collection pressure and performance degradation. ExposingforEachEdgeperforms inline parsing of the composite string key delimiter (\x00) and passes scalar arguments (strings/numbers) straight to the callback without intermediate object allocations, safely maintaining the underlying encapsulation of theGraphclass.📊 Impact: Reduces array memory allocation and Garbage Collection spikes for large graph processing, visibly improving execution speed during metrics calculations without any regression to functionality or architectural boundaries.
🔬 Measurement: Verified the improvement by running large-scale graph tests using Vitest (e.g.
pnpm test tests/pagerank_perf_large.test.tsandtests/hits_perf_large.test.ts), which executed significantly faster. Allpnpm testcases pass.PR created automatically by Jules for task 15909475517467732390 started by @saurabhsharma2u