pydata / pydata/xarray

interp() performance regression in 2025.1.0+

Open
#10,683 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-interpolation topic-performance
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

What happened?

A performance regression has been introduced between 2024.11.0 and 2025.1.0, possibly in #9881, as was the case in #10287. This issue is still present in 2025.8.0. In the example running on my machine it is a 76x performance regression. It seems to be present when interpolating 2D arrays but the degradation is more extreme with 3D arrays.

What did you expect to happen?

No performance regression.

Minimal Complete Verifiable Example
import numpy as np
import xarray as xr

import time

n_repeats = 10

# array dims
n_t = 122
n_r = 65
n_z = 65

# generate some random data to interpolate
rng = np.random.default_rng(seed=42)

data = rng.random((n_t, n_r, n_z))
data_t = np.linspace(0.01, 0.855, n_t)
data_r = np.linspace(0.04, 4., n_r)
data_z = np.linspace(-1.2, 1.2, n_z)

da = xr.DataArray(
    data=data,
    dims=["t", "r", "z"],
    coords=dict(
        t=data_t,
        r=data_r,
        z=data_z,
    ),
)

interp_z_data = rng.random((n_t))
interp_z = xr.DataArray(
    data=interp_z_data,
    dims=["t"],
    coords=dict(
        t=data_t,
    ),
)

start = time.time()
for _ in range(n_repeats):
    # regression is here:
    da.interp(z=interp_z)
end = time.time()

t_elapsed = end - start
print(f"Time elapsed: {t_elapsed}")
MVCE confirmation
  • Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • Complete example — the example is self-contained, including all data and the text of any traceback.
  • Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • New issue — a search of GitHub Issues suggests this is not a duplicate.
  • Recent environment — the issue occurs with the latest version of xarray and its dependencies.
Relevant log output
pip install "xarray==2024.11.0"
python test.py
Time elapsed: 0.22251605987548828

pip install "xarray==2025.1.0"
python test.py
Time elapsed: 16.765803813934326
Anything else we need to know?

No response

Environment
INSTALLED VERSIONS ------------------ commit: None python: 3.13.7 (main, Aug 14 2025, 00:00:00) [GCC 15.2.1 20250808 (Red Hat 15.2.1-1)] python-bits: 64 OS: Linux OS-release: 6.16.3-200.fc42.x86_64 machine: x86_64 processor: byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: ('en_GB', 'UTF-8') libhdf5: None libnetcdf: None

xarray: 2025.1.0
pandas: 2.3.2
numpy: 2.3.2
scipy: 1.16.1
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
zarr: None
cftime: None
nc_time_axis: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: None
cartopy: None
seaborn: None
numbagg: None
fsspec: None
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: None
pip: 24.3.1
conda: None
pytest: None
mypy: None
IPython: None
sphinx: None

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided interp() minimal example against the stated xarray versions to reproduce the regression, then inspect the interpolation path used for 2D and 3D arrays. Done means restoring performance near the pre-2025.1.0 behavior and adding a regression test or benchmark for the demonstrated case.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.