Skip to content

Fix performance regression with limit on unordered queries#90

Merged
j6k4m8 merged 1 commit intoaplbrain:masterfrom
davidmezzetti:master
Nov 13, 2025
Merged

Fix performance regression with limit on unordered queries#90
j6k4m8 merged 1 commit intoaplbrain:masterfrom
davidmezzetti:master

Conversation

@davidmezzetti
Copy link
Contributor

@davidmezzetti davidmezzetti commented Nov 13, 2025

Re-submitting PR (same as #87) with recent changes merged in.

I also had to make another change due to a separate error that came up with the latest commit. It looks like the new auto_node_jsondata_hints feature assumes the graph is a DiGraph. Having that enabled was raising an error from grandiso saying host has no attribute pred. Without this change, I was receiving the following stacktrace.

AttributeError: 'Graph' object has no attribute 'pred'
Traceback:

File "python3.10/site-packages/grandcypher/__init__.py", line 1708, in run
    return self._transformer._executors[0].returns()
File "python3.10/site-packages/grandcypher/__init__.py", line 897, in returns
    results = self._lookup(
File "python3.10/site-packages/grandcypher/__init__.py", line 675, in _lookup
    true_matches = self._get_true_matches()
File "python3.10/site-packages/grandcypher/__init__.py", line 1102, in _get_true_matches
    for match in self._matches_iter(my_motif):
File "python3.10/site-packages/grandcypher/__init__.py", line 1190, in _matches_iter
    for match in grandiso_finder:
File "python3.10/site-packages/grandiso/__init__.py", line 427, in find_motifs_iter
    yield from walk(path)
File "python3.10/site-packages/grandiso/__init__.py", line 412, in walk
    for candidate in get_next_backbone_candidates(
File "python3.10/site-packages/grandiso/__init__.py", line 260, in get_next_backbone_candidates
    candidate_nodes_from_this_edge = host.pred[backbone[target]]

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 13, 2025

CodSpeed Performance Report

Merging #90 will improve performances by ×3.8

Comparing davidmezzetti:master (ecee781) with master (76e458e)

Summary

⚡ 2 improvements
✅ 95 untouched

Benchmarks breakdown

Benchmark BASE HEAD Change
test_limit_only 107.6 ms 28.4 ms ×3.8
test_skip_and_limit 215.2 ms 138 ms +55.95%

@j6k4m8
Copy link
Member

j6k4m8 commented Nov 13, 2025

this is awesome — good to merge in?? thanks for chasing down the extra merge confs :)

@j6k4m8
Copy link
Member

j6k4m8 commented Nov 13, 2025

ahh that's a great catch on the digraphs... we should hit that in a test, @khoale88

@davidmezzetti
Copy link
Contributor Author

I think this is good to merge in. @khoale88 might have a better way to work around the DiGraph issue I was encountering, could be a deeper issue there.

@j6k4m8
Copy link
Member

j6k4m8 commented Nov 13, 2025

Super, thank you @davidmezzetti !! This is a snazzy performance bump :)

@j6k4m8 j6k4m8 merged commit e9dcd88 into aplbrain:master Nov 13, 2025
7 checks passed
@khoale88
Copy link
Contributor

Please create an issue so we dont forget about it.

@davidmezzetti
Copy link
Contributor Author

Please create an issue so we dont forget about it.

I added #91 to let you take a look and determine if further action is needed.

@j6k4m8
Copy link
Member

j6k4m8 commented Nov 14, 2025

Thank you @davidmezzetti — really appreciate this fix + bug report!

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.

3 participants