Optimize GenerateXdmf#7296
Open
hen-w wants to merge 4 commits into
Open
Conversation
0767ef4 to
0a7a69c
Compare
Instead of loading and walking the mixed-topology connectivity array in Python, read the cell count from len(observation["ElementId"]) which is free HDF5 metadata. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Avoid repeated HDF5 metadata lookups by caching the component list and dtypes. The cache is invalidated when the dataset count changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Cache grid metadata (num_points, number_of_cells, connectivity lengths) in _ObservationCache. In fast mode, all HDF5 metadata is read only once and reused for every timestep. This gives a large speedup on slow filesystems when the grid and variables are static. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Bug 1: the cell count read once from 'ElementId' counts the *main* connectivity's cells and was then reused for the pole-filling Mixed topology, whose 'pole_connectivity' has a different, time-varying cell count. The pole topology therefore reported the main grid's NumberOfElements. Restore counting the pole connectivity's own cells (per observation, since it can change between timesteps); the main connectivity keeps the free len(ElementId) count. Bug 2: the component/dtype cache was invalidated only when the *number* of datasets changed. If the set of observed fields changes while the count stays the same, the stale field list was reused, emitting an attribute that points at a non-existent dataset and dropping the field that is actually present. Caching is now gated entirely on --fast-mode: the default mode re-reads component names and dtypes on every observation (always correct), while --fast-mode reads them once (the user already asserts that the grid and variables are static). Adds unit tests that trigger both bugs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
wthrowe
reviewed
Jun 16, 2026
wthrowe
left a comment
Member
There was a problem hiding this comment.
Looks fine. Please squash in some manner so that there are not broken commits in the middle.
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.
Proposed changes
Various optimizations of
GenerateXdmf.py. This results in 60 times speed up for large volume files.Upgrade instructions
Code review checklist
make docto generate the documentation locally intoBUILD_DIR/docs/html.Then open
index.html.code review guide.
bugfixornew featureif appropriate."Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com",
"Co-Authored-by: Codex noreply@openai.com", or
"Co-Authored-By: GitHub Copilot CLI noreply@microsoft.com"
as the last line of the commit, depending on the agent.
Further comments