Skip to content

Extend pathfinding asv benchmarks to dask/cupy backends and multi_stop_search#3648

Open
brendancol wants to merge 1 commit into
mainfrom
deep-sweep-benchmarks-pathfinding-2026-07-08
Open

Extend pathfinding asv benchmarks to dask/cupy backends and multi_stop_search#3648
brendancol wants to merge 1 commit into
mainfrom
deep-sweep-benchmarks-pathfinding-2026-07-08

Conversation

@brendancol

Copy link
Copy Markdown
Contributor

Closes #3645

  • Parameterize AStarSearch over numpy / cupy / dask and raise the size ladder to [100, 300, 1000] (was numpy-only at [10, 100, 300]). The dask backend is a separate implementation (_a_star_dask, sparse Python A* with an LRU chunk cache) that previously had no benchmark at all.
  • Skip dask at nx=1000 via NotImplementedError in setup: a single call takes ~4 s and would dominate suite runtime. dask still runs chunked (2x2 chunks) at 100 and 300.
  • Add MultiStopSearch: 4 waypoints across the grid, timing both ordered routing and optimize_order=True (Held-Karp path), on numpy / cupy / dask at [100, 300].
  • snap_start/snap_goal stay on for numpy/cupy (matching the old benchmark) and off for dask, where they raise by design.

Benchmark-only change; xrspatial/pathfinding.py is untouched. dask+cupy is still not parameterized because common.get_xr_dataarray has no such type anywhere in the suite; noted in #3645.

Backend coverage: numpy, cupy, dask+numpy benchmarked; dask+cupy not (suite-wide gap).

Test plan:

https://claude.ai/code/session_0155N4QGamQVxgpAAPbpQNq4

…3645)

The pathfinding benchmark only ran a_star_search on numpy at nx<=300.
Parameterize AStarSearch over numpy/cupy/dask and add nx=1000 (dask
capped at 300: the sparse Python A* takes ~4s per call at 1000). Add a
MultiStopSearch class timing ordered routing and optimize_order.

Every combo was executed locally, including cupy on a GPU host.
Benchmark-only change; no edits to xrspatial/pathfinding.py.

Claude-Session: https://claude.ai/code/session_0155N4QGamQVxgpAAPbpQNq4
@brendancol brendancol added backend-coverage Adding missing dask/cupy/dask+cupy backend support performance PR touches performance-sensitive code tests Test coverage and parity area:pathfinding Area: pathfinding labels Jul 8, 2026

@brendancol brendancol left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Domain-aware review of the benchmark changes.

Blockers

None. The change is benchmark-only, xrspatial/pathfinding.py is untouched, and every runnable parameter combination was executed on a GPU host per the PR body.

Suggestions

None.

Nits

  1. Changing AStarSearch.params (new sizes and backend axis) resets the asv history for this class, so old numpy timings won't line up with new ones in the dashboard. Unavoidable when adding a backend axis, just something to know when reading trends across this commit.
  2. MultiStopSearch.setup builds waypoints from self.agg.y.data[...] numpy scalars while AStarSearch uses self.agg.y[0] DataArray scalars. Both are accepted by the API (_get_pixel_id floats them), so this is style only. The numpy-scalar form is arguably better in setup code since it skips xarray indexing overhead.

Details checked:

  • The dask skip at nx=1000 uses NotImplementedError in setup, the same skip mechanism common.get_xr_dataarray already uses for missing cupy/rtxpy, and asv marks those combos n/a rather than failed.
  • snap_start/snap_goal stay on for numpy/cupy, matching the old benchmark's call signature; they are off for dask where the API raises ValueError by design. Snap on a valid start pixel is O(1) (_find_nearest_pixel returns immediately), so it doesn't distort timings.
  • get_xr_dataarray dask chunks are (ny//2, nx//2), so the dask combos run 2x2 chunked and exercise _a_star_dask's chunk cache for real, not a single-chunk degenerate case.
  • With 4 waypoints, optimize_order=True takes the Held-Karp branch (N <= 12) and issues 12 matrix A* calls plus 3 segment calls, which is the cost profile users of that flag actually hit.
  • Slowest single call is ~1.4 s (dask optimize_order at nx=300), so the added suite runtime is bounded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:pathfinding Area: pathfinding backend-coverage Adding missing dask/cupy/dask+cupy backend support performance PR touches performance-sensitive code tests Test coverage and parity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pathfinding asv benchmark covers only numpy a_star_search; dask/cupy backends and multi_stop_search unbenchmarked

1 participant