Repository navigation
Optimize chunk sizes - #44
Conversation
|
I think this is a better approach of the splitting than mine. Guess the only thing missing is to mention it in the changelog. Originally I had When I did the PR I compared times and concluded that doing as much channels as possible is indeed considerably faster than splitting each time the chunk_size by 2. So I said "lets do it the fastest way" , and decided to decrease the chunk size by --1 instead of //2 and just commented that (though that comment wasn't really expressive).
It was because I wanted the fastest one 😆 , guess it was too much of a greedy algorithm 😅 . I mean the necessary thing was to be fast. Comparing your method and the naive --1 , yours gives a more stable ram consumption. I guess at some points it could make pyprep slower but since it tries to find the fastest method with chunks of roughly the same size I think this is a nice equilibrium point between being fast and using ram in an stable way. So I guess we are establishing ( in the context of your example):
So if everyone agrees on that statement I say that we can merge this. Now, just another remark regarding ram compsuntion. Should this line in run_ransac : Stay like that or be instead a percentage of the ram available (like 70% for example). I guess that if the user is processing and leaving the computer alone is better for it to be 100% but if it is doing something at the same time it would be better a percentage... What do you think? |
There was a problem hiding this comment.
Only thing missing is to include it in the changelog. I mean I think @sappelhoff would ask me to do that xD.
Codecov Report
@@ Coverage Diff @@
## master #44 +/- ##
==========================================
+ Coverage 97.02% 97.08% +0.05%
==========================================
Files 5 5
Lines 505 514 +9
==========================================
+ Hits 490 499 +9
Misses 15 15
Continue to review full report at Codecov.
|
|
I've updated the whats_new and also added a weak implementation of your suggestion: I've made it so it adjusts the I guess we can tune the exact proportion of free memory to use, but I think 95% is a good starting place from a stability vs performance perspective (i.e. we aren't losing much). Does that sound good to you? |
sappelhoff
left a comment
There was a problem hiding this comment.
LGTM apart from one comment I made!
|
Thanks for your first PR to pyprep @a-hurst! may there be many more 🎉 |
PR Description
On my computer running PyPREP typically slows everything down to a crawl, even causing occasional brief screen blackouts as macOS tries to cope with all its RAM being consumed. Obviously this expected to some extent, but I noticed that it will take as much RAM as possible even when not necessary: e.g. the chunk size being set to 57 for a 64-channel dataset when 32 would have produced the same number of chunks with less RAM consumption.
To address this, I've written a bit of code that figures out the smallest possible chunk size for each possible number of chunks for a file. e.g. for 32 channels, we get:
When the largest chunk size is too large, it falls back to the next-largest chunk size in the list, so 32 (1 chunk) -> 16 (2 chunks) -> 11 (3 chunks) -> 8 (4 chunks) etc.
In addition to freeing up some system RAM, this should also reduce the likelihood of an overzealous OS killing off the Python process mid-PREP because it's consumed too large a chunk of RAM (has happened to me twice on an 8GB MBP running Catalina, but never on the 24GB iMac running High Sierra or 16GB Hackintosh running Mojave that I've tested PyPREP extensively with)
Merge Checklist
To merge your PR we need to first take the following points into account:
closes #<issue-number>to automatically close an issue