Skip to content

Filter node attrs without building an rx subgraph#316

Merged
JoOkuma merged 1 commit into
royerlab:mainfrom
JoOkuma:perf-filter-nodes-no-subgraph
Jul 1, 2026
Merged

Filter node attrs without building an rx subgraph#316
JoOkuma merged 1 commit into
royerlab:mainfrom
JoOkuma:perf-filter-nodes-no-subgraph

Conversation

@JoOkuma

@JoOkuma JoOkuma commented Jul 1, 2026

Copy link
Copy Markdown
Member

_filter_nodes_by_attrs built a full rustworkx subgraph — copying every edge between the selected nodes — just to run filter_nodes on the copy and map indices back.

Evaluate the filter function directly on the selected nodes' payload dicts, skipping the O(nodes + edges) subgraph construction. ~1.7x faster on a 50k-node/100k-edge benchmark (13.8 ms → 8.0 ms).

Covered by existing filter tests.

_filter_nodes_by_attrs constructed a full rustworkx subgraph (copying
node payload references and every edge between the selected nodes) just
to run filter_nodes on it, then mapped the indices back through the
node map. Evaluating the filter function directly on the selected
nodes' payload dicts avoids the O(nodes + edges) subgraph construction
and the index round-trip (~1.7x faster on a 50k-node / 100k-edge graph
when filtering half the nodes by attribute).
@JoOkuma JoOkuma merged commit 3047818 into royerlab:main Jul 1, 2026
7 checks passed
@JoOkuma JoOkuma deleted the perf-filter-nodes-no-subgraph branch July 1, 2026 21:35
@JoOkuma JoOkuma restored the perf-filter-nodes-no-subgraph branch July 1, 2026 21:35
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