Accelerate collect() by switching to lazy loading#340
Open
mikekryjak wants to merge 8 commits intomasterfrom
Open
Accelerate collect() by switching to lazy loading#340mikekryjak wants to merge 8 commits intomasterfrom
mikekryjak wants to merge 8 commits intomasterfrom
Conversation
Only opens one file, using metadata to construct Dask chunks for all other files. This greatly reduces the time needed to open a dataset.
Sorting out imports
If opening a set of NetCDF files that are all in the same directory, use lazy_open_boutdataset. This is a common use-case and is significantly faster this way. For more complicated cases (e.g. concatenating multiple BOUT++ runs), or if `lazy_load = False`, fall back to the old method.
Merge ds.metadata only if it exists.
Testing uses lists of datasets rather than glob string input.
Falls back to the original method if this doesn't work.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is another change that Claude came up with after #337. It rewrites
xbout.load.collect()to use the newlazyload.lazy_open_boutdataset()from #336. It falls back on the original method if things break. It also makes minor improvements to the code, like not relying on the coordinates not being in a specific order.Test results:
So we are now 200x faster than before, and also 40% faster than
boutdata. I suppose the difference could be using Dask.For completeness, the same dataset takes 2.5s to load in its entirety using the latest lazy loading.
This PR contains #336 and should be merged after.