fix: bolt optimization to avoid object materialization for graph exports - #1014
fix: bolt optimization to avoid object materialization for graph exports#1014n24q02m wants to merge 1 commit into
Conversation
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>
|
👋 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. |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
|
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. |
What: Introduced
iter_all_nodes_rawanditer_all_edges_rawmethods inGraphStorethat yieldsqlite3.Cursorand replaced uses ofget_all_nodesandget_all_edgesinsideexporter.pyformat functions to iterate over raw rows as dictionaries instead of fully materializing Python wrapper objects (likeGraphNodeorGraphEdge) 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 inexport_crg) or large repositories in typicalexport_*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 usingtracemalloc. 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