Restore memory efficiency - #75
Conversation
|
After the change, the memory usage for the to |
| # Sets the founder anterior values and penetrance value for Heuristic peeling. | ||
| for ind in pedigree: | ||
| ind.setPeelingView() | ||
| ind.setPeelingView(bool(args.seg_output)) |
There was a problem hiding this comment.
I personally like to add arg keyword as it makes code clearer to me, but I don't know what's the preferred/popular Python style;) Your call @XingerTang!
There was a problem hiding this comment.
The whole args might be unnecessary here. I can make seg_outputa variable that is assigned earlier separately; it would be like:
seg_output = bool(args.seg_output)
for ind in pedigree:
ind.setPeelingView(seg_output)
There was a problem hiding this comment.
I agree it's not needed. I personally prefer code like ind.setPeelingView(store_out_segregation = bool(args.seg_output)) or ind.setPeelingView(store_out_segregation = seg_output), but that's just my taste. You decide what works best for this codebase!
There was a problem hiding this comment.
I updated the code to the latter way. Python requires all positional arguments to come before any keyword arguments; I usually do not specify the keyword if it can be positional during development to avoid the ordering issue. But this one only has one argument, so it doesn't matter.
gregorgorjanc
left a comment
There was a problem hiding this comment.
Looks like a simple change! Great.
|
In 7ac3f4f, the memory is no longer allocated to the segregation prob output vector if that is not required. While the pytest memray benchmark results are promising, the experiment with the real data is not as effective as expected. In the early version Before this change ( After the commit, without There is a significant decrease after the change, but it is not as much as the difference between Therefore, in 46d2ca1, I cleared the peeling_view when seg_output is not requested. |
|
After 46d2ca1, the memory usage dropped to which the |
|
A possible source of the difference of dc5595f restored the original probability storage pattern without affecting the haplotype and genotype matching. The memray profile on pytest still stay the same, but the real data result might be different. |
|
The memory usage for dc5595f on the same data gives: which I'm quite happy to see.
|
|
@XingerTang this is great testing! I assume all accuracy metrics and runtime are unaffected - good to check. I am asking because I see you are not storing or you are clearing some objects, which is what we want so I guess this is all fine and gives you lower memory footprint, but you seem to have to do some extra work with |
All the metrics are the same, and essentially the output files are exactly the same. There are more temporary holders (such as |
Excellent - all is well then. Well done on cracking this memory issue! |
|
There are some issues with GitHub Action runners: https://www.githubstatus.com/ |
|
I think it's okay we ignore the failing tests (all caused by the GitHub runner issue) and merge |
| [project] | ||
| name = "AlphaImpute2" | ||
| version = "0.0.4" | ||
| version = "0.0.5" |
There was a problem hiding this comment.
@XingerTang I suggest we also add maintainers here and later co-authors.
|
I agree - all the failures are due to outage on GitHub side. Add the maintainers and merge;) |
7a0a314 to
ae67a85
Compare
What changed
Why this change
Notes / Risks