Skip to content

Quadratic definition time in xarray.DataArray.to_zarr(compute=False)#12299

Merged
crusaderky merged 2 commits intodask:mainfrom
crusaderky:to_zarr_quadratic
Feb 19, 2026
Merged

Quadratic definition time in xarray.DataArray.to_zarr(compute=False)#12299
crusaderky merged 2 commits intodask:mainfrom
crusaderky:to_zarr_quadratic

Conversation

@crusaderky
Copy link
Copy Markdown
Collaborator

@crusaderky crusaderky commented Feb 19, 2026

Closes #12298

Reduce the time it takes for xarray.DataArray.to_zarr(..., compute=False) to return a delayed object from O(n^2) to O(n), where n is the total number of tasks in the graph.

In my production environment, this reduces the time it takes to store the metadata of an array backed by a ~70k tasks graph from 3 minutes to 2 seconds.

Read #12298 for full explanation and analysis.

No unit test since, AFAIK, there are no microbenchmarks available?

@github-actions
Copy link
Copy Markdown
Contributor

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

     21 files  ±0       21 suites  ±0   5h 4m 6s ⏱️ - 3m 58s
 18 284 tests ±0   17 010 ✅ ±0   1 274 💤 ±0  0 ❌ ±0 
294 787 runs  ±0  252 444 ✅ ±0  42 343 💤 ±0  0 ❌ ±0 

Results for commit 949cead. ± Comparison against base commit 6ac1553.

@dcherian
Copy link
Copy Markdown
Collaborator

Thank you! We've seen many reports of it and have recommend people just use chunksize=-1, most of the time no one actually computes the returned Delayed anyway, it is simply used for writing a schema.

@crusaderky crusaderky merged commit 4195f5a into dask:main Feb 19, 2026
29 checks passed
@crusaderky crusaderky deleted the to_zarr_quadratic branch February 19, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xarray's to_zarr(compute=False) has quadratic definition time

2 participants