Point interpolation is (too?) slow #2902
Replies: 5 comments 9 replies
-
I have profiled the above test case using py-spy, and this is what I get on master: |
Beta Was this translation helpful? Give feedback.
-
Are the costs due to the interpolation, or building the tree? libsupermesh uses bulk loading, and afaict Firedrake is adding nodes one at a time using |
Beta Was this translation helpful? Give feedback.
-
Some thoughts:
|
Beta Was this translation helpful? Give feedback.
-
Opened #2909 which fixes this. If it passes tests then it should be merged. |
Beta Was this translation helpful? Give feedback.
-
Fixed by #2909 |
Beta Was this translation helpful? Give feedback.
-
Despite @ReubenHill 's improvements in 81644ff I have found point interpolation for large point sets to still be fairly slow. I in particular noticed this comparing mesh-to-mesh interpolation in an adaptive mesh simulation with the same setup in fluidity. In fluidity the time spent on interpolation is pretty much negligible whereas in my firedrake setup it dominates by an order of magnitude - taking the time of a dozen Stokes timesteps, making adaptivity pointless. I know @jrmaddison and @pefarrell have in the past spent a lot of time optimising the node/intersection finder in fluidity and much of this has been transferred to libsupermesh. So this brought me to the idea of just trying to use the rtree node locator used internally by libsupermesh and indeed doing so it seems I can bring down the cost of interpolation by a factor of 20.
Take the following test example:
This interpolates to ~ 40,000 nodes and takes about 2 minutes on master whereas using the rtree configuration of libsupermesh it takes less than 5 seconds. To reproduce the latter you need https://bitbucket.org/stephankramer/libsupermesh/branch/skramer/expose-rtree-c-interface to expose the c interface to libspatialindex's rtree as it's internally used in libsupermesh and use the skramer/libsupermesh-rtree branch of Firedrake.
To be honest, I don't really understand why firedrake's use of libspatialindex's rtree is so much slower.
Index_Intersects_id
just creates a Region and calls theintersectsWithQuery()
method on the rtree index for every queried point, which is pretty much what is done inlibsupermesh_query_rtree()
except that it creates a Point. I tried writing my own version ofIndex_Intersects_id
that still uses firedrake's created rtree object but uses a Point instead, but that didn't seem to make any difference. So it must be something in the configuration of the rtree index that is different.Beta Was this translation helpful? Give feedback.
All reactions