Skip to content

fix: bolt optimization to avoid object materialization for graph exports - #1014

Closed
n24q02m wants to merge 1 commit into
mainfrom
bolt-optimize-export-materialization-12815269464629342211
Closed

fix: bolt optimization to avoid object materialization for graph exports#1014
n24q02m wants to merge 1 commit into
mainfrom
bolt-optimize-export-materialization-12815269464629342211

Conversation

@n24q02m

@n24q02m n24q02m commented Sep 5, 2026

Copy link
Copy Markdown
Owner

What: Introduced iter_all_nodes_raw and iter_all_edges_raw methods in GraphStore that yield sqlite3.Cursor and replaced uses of get_all_nodes and get_all_edges inside exporter.py format functions to iterate over raw rows as dictionaries instead of fully materializing Python wrapper objects (like GraphNode or GraphEdge) into lists.

Why: Using .fetchall() or list materialization on large database result sets forces SQLite to allocate heavy lists of mapped Python objects into memory. This is especially problematic for large text-columns (like in export_crg) or large repositories in typical export_* endpoints. Iterating directly on the cursor using standard row dictionary lookup bypasses memory bloat entirely.

Impact: Substantially lowers the peak memory footprint during any full graph export (GraphML, JSON-LD, Dot, Cypher, and CRG exports). Avoids O(N) list-appends of Python ORM objects where N = total graph nodes/edges. Memory scales constantly (only tracking generator state) instead of linearly.

Measurement: Run export_graph() on a large repository and measure memory using tracemalloc. Comparing memory footprint against the previous implementation yields significantly lower allocations since nodes/edges are garbage collected dynamically rather than hoarded in a list before serialization.


PR created automatically by Jules for task 12815269464629342211 started by @n24q02m

Introduces raw iterator methods (`iter_all_nodes_raw`, `iter_all_edges_raw`) to `GraphStore` and refactors `exporter.py` functions (`export_graphml`, `export_jsonld`, `export_dot`, `export_cypher`, `export_crg`) to bypass materialization of `GraphNode` and `GraphEdge` objects in lists, heavily reducing memory overhead for large graph exports.

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

Copy link
Copy Markdown
Contributor

👋 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.

@github-actions github-actions Bot added the bot-generated Automatically created by a bot tool (Jules, Bolt, Palette, etc.) label Sep 5, 2026
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@n24q02m

n24q02m commented Sep 10, 2026

Copy link
Copy Markdown
Owner Author

Closing: competing variant (iter_all_nodes_raw) of the design landed by #1015.

@n24q02m n24q02m closed this Sep 10, 2026
@google-labs-jules

Copy link
Copy Markdown
Contributor

Closing: competing variant (iter_all_nodes_raw) of the design landed by #1015.

Understood. Acknowledging that this work is obsolete and a competing variant landed. Stopping work on this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-generated Automatically created by a bot tool (Jules, Bolt, Palette, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant