Make small AuxCoords (including scalar) non-lazy, for efficiency #5069
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #5053.
The tiny fix here seems to show that the slowness is largely due to creating lots of tiny lazy coords (for scalar coords).
This really speeds up the testcase for netcdf load -- from ~150sec to ~4secs ...
(testcase is a file with ~200 variables all of which have 2 scalar coords)
Here we are making any smaller AuxCoords real : we fetch variable data immediately to make a new coord, instead of giving it a "dask.Array wrapping a NetcdfDataProxy referring to a file variable".
In practice, if the size threshold is set right, this approach should save memory too.
But it's not trivial to determine what a typical minimal overhead for a "dask.Array wrapping a NetcdfDataProxy" actually is.
At least the NetcdfDataProxy object is pretty small + simple, containing some numbers + a couple of strings. The Dask array object is probably more costly.
TBD