Skip to content

⚡ Bolt: [performance improvement] Replace getEdges() with memory-efficient forEachEdge()#100

Draft
saurabhsharma2u wants to merge 1 commit intomainfrom
bolt-graph-foreach-edge-optimization-12845013787333598539
Draft

⚡ Bolt: [performance improvement] Replace getEdges() with memory-efficient forEachEdge()#100
saurabhsharma2u wants to merge 1 commit intomainfrom
bolt-graph-foreach-edge-optimization-12845013787333598539

Conversation

@saurabhsharma2u
Copy link
Contributor

💡 What: Implemented a new forEachEdge method on the Graph class that iterates directly over the internal edges Map and decodes the composite key inline. Replaced all performance-critical usages of graph.getEdges() with graph.forEachEdge(...) in hits.ts, pagerank.ts, and metrics.ts.

🎯 Why: Calling graph.getEdges() inside these hot loops caused massive array and object allocations (creating an array of {source, target, weight} objects for every edge in the graph), leading to significant garbage collection overhead, especially for massive site graphs.

📊 Impact: Reduces heap memory usage substantially during PageRank and HITS calculations, making the application measurably faster and more efficient on large datasets by avoiding full array allocations.

🔬 Measurement: Run pnpm --filter core test to verify functional correctness and see the benchmark outputs from pagerank_perf_large.test.ts and hits_perf_large.test.ts.


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

… paths

- Added `forEachEdge` to Graph to iterate edges without array allocations
- Refactored `hits.ts`, `pagerank.ts`, and `metrics.ts` to use `forEachEdge`
- Updated `metrics.ts` to use `graph.edges.size` instead of mapping edges
- Verified HITS and PageRank tests to ensure functional correctness and benchmark improvement
@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