8000 PERF: eliminate redundant sorting by martinfleis · Pull Request #793 · pysal/libpysal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

PERF: eliminate redundant sorting #793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

martinfleis
Copy link
Member

Within gwlearn bandwidth search, we generate quite large graphs and it turned out that the bottleneck is not model fitting but graph creation. Especially sorting and reindex we do, and which we do at multiple spots even though one shall be enough. Removing some obvious redundancies here but there's a likelihood that some other performance-focused PRs will follow.

Comment on lines -45 to +50
sorter = sparray.row.argsort(**argsort_kwds)
head = ids[sparray.row][sorter]
tail = ids[sparray.col][sorter]
data = sparray.data[sorter]
head = ids[sparray.row]
tail = ids[sparray.col]
data = sparray.data
else:
sorter = sparray.row.argsort(**argsort_kwds)
head = sparray.row[sorter]
tail = sparray.col[sorter]
data = sparray.data[sorter]
head = sparray.row
tail = sparray.col
data = sparray.data
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary as _resolve_islands does this. And if it does not go through there, it is done in clique resolution.

@@ -1085,7 +1085,7 @@ def build_kernel(
coplanar=coplanar,
)

return cls.from_arrays(head, tail, weight)
return cls.from_arrays(head, tail, weight, is_sorted=True)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above, output of _kernel is known to be sorted.

@martinfleis martinfleis requested review from ljwolf and jGaboardi June 9, 2025 15:08
@martinfleis
Copy link
Member Author

CI is not failing because of this but because of missing upper pin in numba-feedstock that is being resolved independently by others.

@jGaboardi jGaboardi added rough edge Something that's not a bug, but that gets in the way of "it just works." graph labels Jun 9, 2025
@jGaboardi
Copy link
Member

xref – conda-forge/numba-feedstock#157

8A94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
graph rough edge Something that's not a bug, but that gets in the way of "it just works."
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0