Skip to content

⚡ Bolt: Optimize graph edge iteration for PageRank and HITS#97

Draft
saurabhsharma2u wants to merge 1 commit intomainfrom
bolt-optimize-graph-iteration-15909475517467732390
Draft

⚡ Bolt: Optimize graph edge iteration for PageRank and HITS#97
saurabhsharma2u wants to merge 1 commit intomainfrom
bolt-optimize-graph-iteration-15909475517467732390

Conversation

@saurabhsharma2u
Copy link
Contributor

💡 What: Added a memory-efficient forEachEdge iterator to the Graph class and updated the PageRankService and HITSService algorithms to use it instead of calling graph.getEdges().

🎯 Why: Calling graph.getEdges() inside these algorithm setups was previously mapping every single edge in the graph.edges Map 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. Exposing forEachEdge performs 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 the Graph class.

📊 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.ts and tests/hits_perf_large.test.ts), which executed significantly faster. All pnpm test cases pass.


PR created automatically by Jules for task 15909475517467732390 started by @saurabhsharma2u

@google-labs-jules
Copy link

👋 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