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

Use a serde visitor in inspect to avoid buffering the full database #27

Merged
merged 2 commits into from
Nov 7, 2024

Conversation

althonos
Copy link
Contributor

@althonos althonos commented Nov 7, 2024

Hi Jim!

In light with the inspect release here's a PR to reduce the memory requirements: using a serde::de::Visitor to visit the database allows to accumulate the stats over the GenomeSketch without having to deserialize the whole Vec<GenomeSketch> in memory. This means now you can sylph inspect gtdb-r220-c200-dbv1.syldb in about the same time but 60MiB of memory. An example for this kind of things can be found here in the serde documentation to process a large JSON file without buffering it first.

NB: I was exploring how to do that with the database during the search as well to avoid having to load the full database, so that it could run on more memory-starved systems. What I had so far worked okay for single threads but didn't parallelize well, however that may be a direction worth exploring.

@bluenote-1577
Copy link
Owner

Hi Martin, this looks brilliant. Thanks so much for your help, as always! I really need to learn more about serde :). Tested and looks good to me.

I thought about not loading the full database for sylph as well, which could lead to better memory costs. Ultimately, for the forseeable future, I don't see dereplicated databases getting too much larger. So the database will be < 30 GB which I think is doable for most folks.

@bluenote-1577 bluenote-1577 merged commit e3f56c4 into bluenote-1577:main Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants