Skip to content

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

Description

@brendancol

Problem

benchmarks/benchmarks/pathfinding.py measures a_star_search on the numpy backend only, at grids up to 300x150. The module has four backend paths and a second public function, and most of that surface has no benchmark:

Function numpy cupy dask dask+cupy
a_star_search nx=10/100/300, conn 4/8 none none none
multi_stop_search none none none none

Gaps:

  1. Backend gap (HIGH). The dask backend is not the numpy kernel behind a wrapper: _a_star_dask is a separate sparse Python A* with an LRU chunk cache, and _path_to_dask_array builds the lazy output block by block. A regression there (say, the chunk cache silently reloading blocks) would not show up in any benchmark. The cupy path (device-to-host fallback around the numba kernel) is also unmeasured.
  2. Missing benchmark (HIGH). multi_stop_search routes N waypoints through repeated A* calls, stitches the segments, and can reorder waypoints via Held-Karp / 2-opt. None of it is benchmarked, directly or indirectly.
  3. Small inputs (MEDIUM). The largest input is 300x150 (~45k cells, below 256x256), and nx=10 mostly measures setup overhead.
  4. Degenerate input (LOW, note only). The input grid has no barriers and no friction, which is the best case for A*. Not fixing here, but worth remembering when reading absolute numbers.

Evidence (executed on this host, CUDA available)

The current benchmark imports and runs (so this is a coverage gap, not a broken benchmark). Candidate timings for the missing paths, per call after warmup:

dask  a_star nx=100   0.039 s
dask  a_star nx=300   0.304 s
dask  a_star nx=1000  3.857 s
cupy  a_star nx=100   0.0017 s
cupy  a_star nx=300   0.0045 s
cupy  a_star nx=1000  0.0486 s
numpy a_star nx=1000  0.0462 s
numpy multi_stop nx=300 ordered    0.0089 s
dask  multi_stop nx=300 ordered    0.2407 s
cupy  multi_stop nx=300 ordered    0.0131 s
numpy multi_stop nx=100 optimize   0.0249 s
dask  multi_stop nx=100 optimize   0.2514 s

Proposed fix (benchmark-only)

Extend benchmarks/benchmarks/pathfinding.py:

  • AStarSearch: parameterize type over numpy / cupy / dask, sizes [100, 300, 1000] (dask capped at 300 via NotImplementedError in setup; the pure-Python dask A* takes ~4 s at nx=1000 and would dominate suite runtime). Drop nx=10. snap_start/snap_goal stay on for numpy/cupy but off for dask, where they raise by design.
  • New MultiStopSearch class: 4 waypoints on numpy / cupy / dask at [100, 300], timing both the ordered path and optimize_order=True.

dask+cupy stays uncovered: the suite's common.get_xr_dataarray has no dask+cupy type, and no benchmark in the suite parameterizes it. Noting it here rather than growing shared benchmark infra in this change.

No source changes to xrspatial/pathfinding.py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:pathfindingArea: pathfindingbackend-coverageAdding missing dask/cupy/dask+cupy backend supportenhancementNew feature or requestperformancePR touches performance-sensitive codeseverity:highSweep finding: HIGHtestsTest coverage and parity

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions