Skip to content

Neighborhood filter reductions are making uxarray imports slow #1706

Description

@cmdupuis3

The new neighborhood filters require support for vectorized reduction kernels:

_MEAN_KERNEL = _make_kernel(lambda window, _: np.mean(window))
_SUM_KERNEL = _make_kernel(lambda window, _: np.sum(window))
_MIN_KERNEL = _make_kernel(lambda window, _: np.min(window))
_MAX_KERNEL = _make_kernel(lambda window, _: np.max(window))
_PTP_KERNEL = _make_kernel(lambda window, _: np.max(window) - np.min(window))
_MEDIAN_KERNEL = _make_kernel(_median)
_VAR_KERNEL = _make_kernel(_variance)
_STD_KERNEL = _make_kernel(lambda window, ddof: np.sqrt(_variance(window, ddof)))
# ``percentile`` is ``quantile`` on a 0-100 scale, so both methods rescale onto
# this one kernel rather than compiling a near-duplicate.
_QUANTILE_KERNEL = _make_kernel(lambda window, q: np.quantile(window, q))

However, this block is resulting in severe performance degradations of uxarray imports, notably affecting the benchmark suites.

In exploratory work with PR #1700, I found that this block can affect thread pooling as well. The strategy seems to be to lazily generate these kernels, which would defer the overeager thread pooling and limit the burden on uxarray imports.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status
📝 To-Do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions