Use Index_CreateWithArray to build mesh spatial index#4865
Merged
Conversation
34ad740 to
b1e96f1
Compare
connorjward
reviewed
Feb 6, 2026
Contributor
connorjward
left a comment
There was a problem hiding this comment.
This is fantastic. So often performance improvements come down to "we were doing something quite silly before".
@achanbour this PR is likely of interest to you, if you haven't seen it yet.
firedrake/mesh.py
Outdated
| cells_ignore) | ||
| with PETSc.Log.Event("cells_data_as"): | ||
| cells_data = cells.ctypes.data_as(ctypes.POINTER(ctypes.c_int)) | ||
| with PETSc.Log.Event("ref_cell_dists_l1_as"): |
Contributor
There was a problem hiding this comment.
This seems like an unnecessary number of events to be timing.
Contributor
Author
There was a problem hiding this comment.
I will remove these before merging
Contributor
There was a problem hiding this comment.
Ah OK. In future if you ask me for a review please tell me if I can ignore bits of it.
Contributor
There was a problem hiding this comment.
And you should definitely leave some of them in there
b1e96f1 to
5ed3e91
Compare
e59d7ec to
7f284ce
Compare
dham
approved these changes
Feb 19, 2026
sghelichkhani
pushed a commit
to sghelichkhani/firedrake
that referenced
this pull request
Feb 21, 2026
…ject#4865) * add log event markers * build spatial index using CreateWithArray
j-bowhay
pushed a commit
to j-bowhay/firedrake
that referenced
this pull request
Feb 24, 2026
…ject#4865) * add log event markers * build spatial index using CreateWithArray
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before we were looping over bounding box coords and calling
Index_InsertDataone by one which was a big bottleneck. libspatialindex has a function which can build a spatial index in one go from an array: https://libspatialindex.org/en/latest/doxygen/sidx__api_8cc.html#a36737b1629d8a96458e7f437484f5a84Building the spatial index in this example went from ~15s on my machine to ~0.9s