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

Reading plaintext alignments consumes a lot of memory (workaround inside) #24

Closed
tmaklin opened this issue Dec 1, 2023 · 4 comments
Closed
Labels
bug Something isn't working
Milestone

Comments

@tmaklin
Copy link
Collaborator

tmaklin commented Dec 1, 2023

Reading a plaintext pseudoalignment from Themisto consumes a lot more memory than is necessary because plaintext input disables the internal encoding of the pseudoalignments as a sparse vector.

Workaround: use alignment-writer to compact the alignment file and then read in the compact alignment file instead of the plaintext one.

@tmaklin tmaklin added the bug Something isn't working label Dec 1, 2023
@jnalanko
Copy link
Contributor

jnalanko commented Dec 7, 2023

I'm using this workaround, and the memory usage went from over 1TB to only 20GB. However, mSWEEP is still very slow to read the pseudoalignment file. It has now been reading the file for 11 CPU hours at 4 threads. The compacted alignment file is only about 250MB, so that does not sound right.

@tmaklin
Copy link
Collaborator Author

tmaklin commented Dec 8, 2023

The "reading" part also includes deserializing the pseudoalignment into memory, constructing equivalence classes, and assigning the reads to the equivalence classes so it's a bit more than just reading the file, but still this probably needs some design changes to handle large input (100 000 000 reads x 60 000 references in this example) better.

@tmaklin
Copy link
Collaborator Author

tmaklin commented Dec 8, 2023

Relevant functions for this issue:

Deserializing the file

Memory use in plaintext data

Equivalence classes

  • telescope::Alignment::collapse Converting the deserialized file into equivalence classes, where...
  • telescope::GroupedAlignment::insert does the construction of the equivalence classes by hashing the pseudoalignment for each read represented as a boolean vector and constructing a hash map that links the pseudoalignment to data about it.

@tmaklin tmaklin added this to the v2.1.0 milestone Feb 21, 2024
@tmaklin tmaklin mentioned this issue May 30, 2024
@tmaklin
Copy link
Collaborator Author

tmaklin commented May 30, 2024

v2.1.0 should contain a fix for this.

I've also implemented a flag to filter out targets that have 0 alignments across reads, this can reduce the memory and cpu use significantly for sparse inputs. Filtering can be toggled with --min-hits 1. Using 1 as the threshold should produce the same results for the targets that have more than 0 alignments. Using values higher than 1 is also supported but will change the results, however something like --min-hits 1000 can be hugely beneficial for very large inputs.

@tmaklin tmaklin closed this as completed May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants