⚡ Bolt: [performance improvement] Cache graph node and edge subsets#774
⚡ Bolt: [performance improvement] Cache graph node and edge subsets#774
Conversation
Co-authored-by: georgi <19498+georgi@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. |
Co-authored-by: georgi <19498+georgi@users.noreply.github.com>
…rSEOProvider Co-authored-by: georgi <19498+georgi@users.noreply.github.com>
Co-authored-by: georgi <19498+georgi@users.noreply.github.com>
💡 What:
Introduced caching to the
Graphclass insrc/nodetool/workflows/graph.pyfor methods:inputs(),outputs(),get_control_edges(), andget_controlled_nodes(). These caches are properly invalidated and rebuilt when the number of nodes or edges changes.🎯 Why:
The original implementation performed list comprehensions over
self.nodesandself.edgesevery time these methods were called. For large graphs or frequent queries, this caused significant overhead (O(N) and O(E) complexity). By caching the results (similar to how_outgoing_edges_cachewas implemented), we reduce the cost of repeated calls to amortized O(1).📊 Impact:
In synthetic benchmarks simulating typical graph loads (1000 input/output nodes, 10,000 intermediate nodes, 10,000 edges), execution times for these repeated methods dropped dramatically:
inputs()/outputs()queries over 1000 iterations: Dropped from ~0.55s down to ~0.013s (40x speedup)get_control_edges()/get_controlled_nodes()queries over 1000 iterations: Dropped from ~0.73s to ~0.13s (5x speedup)🔬 Measurement:
A custom script
benchmark_graph.pywas used to measure query speed, iterating through nodes/edges across 1000 cycles. Unit tests intests/workflows/test_graph.pywere run to confirm no functional regressions exist.PR created automatically by Jules for task 12794204615594418618 started by @georgi