Skip to content

Reader performance fixes#49

Open
berkgeveci wants to merge 3 commits intoKitware:masterfrom
berkgeveci:reader-performance-fixes
Open

Reader performance fixes#49
berkgeveci wants to merge 3 commits intoKitware:masterfrom
berkgeveci:reader-performance-fixes

Conversation

@berkgeveci
Copy link
Copy Markdown
Collaborator

Made several improvements to improve read times in the reader.

Replace flatten() with reshape(-1) to avoid copies where the data
is only read. In _load_variable, use a single copy followed by
in-place fill value replacement instead of flatten + np.where
which created three copies.
Track which dimensions changed in SetSlicing and only reload
variables whose dimensions intersect the changed set. Variables
unaffected by the slice change are kept from the previous output.

For example, changing lev now skips all 2D (time, ncol) variables.
With 200 2D + 20 3D variables loaded, lev changes are ~2.5x faster.
Only copy and scan for fill values when the variable actually has a
_FillValue attribute. Most variables default to NaN, making the
comparison a no-op that still scans the entire array. Variables
without fill values now return a zero-copy view from reshape.
@patrickoleary
Copy link
Copy Markdown
Member

looks good. each of the three changes is correct.

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.

2 participants