Open cindytsai opened 2 years ago
Oh my goodness, thank you for this detailed bug report. I will look at it. Off the topic of my head, I think it's likely doing one of the following, many or all of which could be short-circuited with improvements to yt's understanding of the data:
Let me look further, and this is a very helpful bug report.
Thanks for the reply! There is another minor issue about how covering_grid
works in parallel when using MPI. I'm not sure if this should be an independent issue, because I think they might somewhat be related. I'll just put it here.
Even though each MPI rank is only responsible for some part of the output uniform grid, it asks grid data resides in this whole target output region. Which means MPI rank will ask for some grid data that will never be in use. I think this is caused by yt
identifies which grid intersects the region and other index array as a whole, but not according to each MPI rank's responsible region. Maybe it will be better if this line gets the proper grids for each MPI rank, not just chunking by io.
@cindytsai and I dug into this a bit and found this from memray, which makes sense:
0x7fbf1f460740 2.9 GiB malloc 1 icoords at /home/mjturk/yt/yt/yt/geometry/geometry_handler.py:339
0x7fbf1f460740 1.0 GiB calloc 1 <listcomp> at /home/mjturk/yt/yt/yt/data_objects/construction_data_containers.py:1074
0x7fbf1f460740 992.0 MiB malloc 1 _read_fluid_selection at /home/mjturk/yt/yt/yt/frontends/gamer/io.py:102
0x7fbf1f460740 992.0 MiB malloc 1 ires at /home/mjturk/yt/yt/yt/geometry/geometry_handler.py:376
The basic problem is that the fundamental unit that yt is considering when generating coordinates is the grid, and the root grid is 512^3. So it will always generate the icoords for that root grid.
@matthewturk do you think we could, in principle, save memory (and time) by storing icoords in a functional form rather than brute arrays ?
So, I think so. I'm not entirely sure the exact best approach. There are three big ones I see:
I think there's a fourth option ... it's on the tip of my tongue but I can't come up with it. I will think.
covering_grid
consumes too much memorySummary
covering_grid
takes unreasonable large amount of memory to produce a uniform grid.Code for reproduction
Download
Data_000000
Put
Data_000000
and the script below in the same folder.Actual outcome
Using valgrind massif tool to check the memory consumption of this script. It takes
6 GB
in total.npy_alloc_cache
takes5 GB
of memory, which is unexpected.Expected outcome
It shouldn't consume that much memory. Because the dataset contains only uniform grids without any AMR structure (grids are all at level 0), and the output of
covering_grid
dimension is the same as the dimension of data domain,covering_grid
only needs to read data from file and then fill in to the new allocated buffer (512 x 512 x 512 x sizeof(double) ~ 1 GB
).Version Information
pip install .
.