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

Memory management improvements #61

Open
3 tasks
sjordan29 opened this issue Dec 20, 2023 · 2 comments
Open
3 tasks

Memory management improvements #61

sjordan29 opened this issue Dec 20, 2023 · 2 comments

Comments

@sjordan29
Copy link
Contributor

I used memory_profiler for instantiation of Clearwater-riverine and running a few timesteps. The following were interesting findings:

  • the calculate_required_parameters method is very memory intensive, because transport calculations require a few key variables with dimensions of time by the number of edges, which get very large as the time dimension grows.
  • turning off printing intermediate variables in clearwater-modules helped with memory management

cw-r-10s

Next steps:

@aufdenkampe
Copy link
Member

@sjordan29, this is great stuff. Thanks for finding and figuring out how to use memory_profiler!

I created this complementary issue that documents some of the approaches we discussed this week.

sjordan29 added a commit that referenced this issue Dec 29, 2023
@sjordan29
Copy link
Contributor Author

A few key findings from the commit above:

  1. Unsurprisingly, variables with dimensions of ('time', 'nedge') take up the most memory (the number of edges will always be greater than the number of faces (cells))
  2. coeff_to_diffusion has the largest memory of all the variables, even though it has the same dimensions ('time', 'nedge') as the others. this is because it's a float64 whereas the others are float32 (I think because they are read directly from the HDF file and that must be the precision of the RAS output).
  3. Leveraging dask and lazy loading appears to have trade-offs between memory and time. It was faster to sel data from the xarray in memory than from a lazy-loaded xarray (when loading the values).
  4. I still need to do some exploration of the lazy writing. Not currently working as I had expected.

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

No branches or pull requests

2 participants