Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce allocations in NetCDF writer #2772

Merged
merged 3 commits into from
Mar 9, 2024
Merged

Reduce allocations in NetCDF writer #2772

merged 3 commits into from
Mar 9, 2024

Conversation

Sbozzolo
Copy link
Member

@Sbozzolo Sbozzolo commented Mar 8, 2024

Every time write_field is called for a NetCDF writer, the code would allocate small vectors containing the desired target dimension. Once the file is written the first time, such vectors were only used to ensure that the target file contains consistent information. This PR moves this check one at higher level, removing the need to allocate the vectors.

The function that is allocating is target_coordinates, that now is called only when writing the file the first time.

This PR also fixed an unrelated import error.

@Sbozzolo Sbozzolo changed the title Reduce allocations in NetCDF writer. Reduce allocations in NetCDF writer Mar 8, 2024
@Sbozzolo Sbozzolo force-pushed the gb/diagnostics_ready branch 2 times, most recently from cc99636 to a813cb0 Compare March 8, 2024 18:52
@Sbozzolo
Copy link
Member Author

Sbozzolo commented Mar 8, 2024

(This barely changed the allocations, as most of them are in NCDataset.)

@Sbozzolo Sbozzolo force-pushed the gb/diagnostics_ready branch from 53a29e3 to 1169bc2 Compare March 8, 2024 19:18
@Sbozzolo Sbozzolo added this pull request to the merge queue Mar 8, 2024
Merged via the queue into main with commit 08fd47e Mar 9, 2024
11 checks passed
@Sbozzolo Sbozzolo deleted the gb/diagnostics_ready branch March 9, 2024 00:22
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