You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ts.samples() is using too much ram when the keyword arguments are specified.
The subsetting by population or time is done on the Python side and it involves copying the tables (twice if pop and time are specified!). See the code here.
For a 3Gb tree sequence this is the ram usage I was getting:
Thanks @mufernando this is very useful. Can you do this again with just a single population please (as in, don't call it in a loop, just call .samples() once each time)? It's not clear how many populations there are, and therefore what size the sample_sets dictionary is (and how big a multiplier this will be).
The operation recap_tsu.samples() should take roughly 4 bytes * num_samples - if not, we have a leak.
I've done some profiling here @mufernando and I don't think we're leaking memory in any major way, so I've removed the "bug" label. The main no parameters code path is definitely returning the right thing, and has the right size and the array.nbytes is the correct value. We can definitely streamline the other code paths, but there's nothing immediate we can do about them (but I've opened #1917 to give a way we can make them a lot better).
I think the "memit" (and memoryprofile stats in general) need to be taken with a pinch of salt. When you see the first example, it looks like calling .samples uses 17MiB which sounds like too much (we have 3.6M samples, so the samples array should use 13.7 MiB). But, this isn't measuring the size of the things in the cell directly, it's measuring the difference in the size of the process overall from the OS's perspective. Numpy asked to malloc 13 MiB, and the OS decided to increase the size of the processes memory space by 17 MiB instead - this is totally normal and exactly what you'd expect.
ah, great, thanks @jeromekelleher! also, I'm not sure if this is a Jupyter thing or not, but if you see the image I had before I edited (with for loops), %%memit said the peak was proportional to the number of loops. Do you think this could indicate Python's garbage collection is screwing us over or is this just a bug of memit? I know something similar was happening when I ran my Python script because of the amount of ram overall it needed to run in our cluster.
Activity
jeromekelleher commentedon Nov 16, 2021
Thanks @mufernando this is very useful. Can you do this again with just a single population please (as in, don't call it in a loop, just call
.samples()once each time)? It's not clear how many populations there are, and therefore what size thesample_setsdictionary is (and how big a multiplier this will be).The operation
recap_tsu.samples()should take roughly 4 bytes * num_samples - if not, we have a leak.mufernando commentedon Nov 16, 2021
I updated the figure!
jeromekelleher commentedon Nov 17, 2021
I've done some profiling here @mufernando and I don't think we're leaking memory in any major way, so I've removed the "bug" label. The main no parameters code path is definitely returning the right thing, and has the right size and the
array.nbytesis the correct value. We can definitely streamline the other code paths, but there's nothing immediate we can do about them (but I've opened #1917 to give a way we can make them a lot better).I think the "memit" (and memoryprofile stats in general) need to be taken with a pinch of salt. When you see the first example, it looks like calling
.samplesuses 17MiB which sounds like too much (we have 3.6M samples, so the samples array should use 13.7 MiB). But, this isn't measuring the size of the things in the cell directly, it's measuring the difference in the size of the process overall from the OS's perspective. Numpy asked to malloc 13 MiB, and the OS decided to increase the size of the processes memory space by 17 MiB instead - this is totally normal and exactly what you'd expect.mufernando commentedon Nov 17, 2021
ah, great, thanks @jeromekelleher! also, I'm not sure if this is a Jupyter thing or not, but if you see the image I had before I edited (with for loops),
%%memitsaid the peak was proportional to the number of loops. Do you think this could indicate Python's garbage collection is screwing us over or is this just a bug ofmemit? I know something similar was happening when I ran my Python script because of the amount of ram overall it needed to run in our cluster.jeromekelleher commentedon Nov 17, 2021
No sure @mufernando, I don't remember the details. I'd like to sort out #1917 and then run your benchark again ideally.
Add direct access to all non-ragged table arrays
Add direct access to all non-ragged table arrays
Add direct access to all non-ragged table arrays
Add direct access to all non-ragged table arrays
Add direct access to all non-ragged table arrays