perf(predict_t_rnas): chunk the input across tRNAscan-SE processes #289 - #451
Open
piotrkica wants to merge 4 commits into
Open
perf(predict_t_rnas): chunk the input across tRNAscan-SE processes #289#451piotrkica wants to merge 4 commits into
piotrkica wants to merge 4 commits into
Conversation
…chwengers#289 Split the sequences into chunks and run one tRNAscan-SE process per chunk with --thread 0.
These helpers are reusable across predictors; keep them next to export_sequences instead of in features/t_rna.py.
Contributor
Author
|
Five out of 6 predictors (pre-CDS) benefit from chunking approach (pilercr does not). I have already tested performance on those and verified the output is unchanged. Holding off with making another PR with this until this is merged. Predictor input-chunking on ERR4333936 (95,607 contigs), baseline vs fixed, allocated cpu = 16
I can add more experiment data in next PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following #289 and
predict_t_rnasperformance.Currently bakta passes cfg.threads to tRNAscan-SE and for metagenomes it is inefficient and reason behind #289 reported performance. Running on single core is much faster for this type of input.
As author in #289 proposed we can split the input into chunks and run one tRNAscan-SE process per chunk with
--thread 0, so the parallelism comes from the processes. I explored some other possibilities, but this is the best approach currently. This is necessary to run on assemblies from e.g. 2GB FASTQ.gz efficiently."Why not run at
--threads 1? Because at--cpu 0cmsearch takes its serial path and never builds the thread pool or the work queue. At--cpu 1it builds both to run a single worker, and that setup is paid on every invocation - two per contig. The difference is 0 to 8% for identical output" - AI summary, worth checking out but performance increase is real.I adapted to current code style. Output is identical — chunks keep input order, are concatenated in order, and I compared the feature list against an unpatched run on many samples. Bakta tests pass. On a single-contig no_chunks = 1 so here logic is the same. For 2-3 contigs you could use hybrid approach e.g. 3 chunks each with 5 cores but i went with simpler approach and the difference is not that meaningful. With more contigs chunking wins.
Peak RSS is not meaningfully higher.
I measured the fix on multiple samples of different size and type.
* efficiency = (--thread 0 / chunked) / 15 cores
** cpu_efficiency = mean cores busy / 15 cores allocated, from cgroups
Tests were done on human gut metagenome samples assembled with megahit and bakta v1.12.1 and full DB v6.0. Measured on m8a.4xlarge vm with 15 threads. Worked on bakta reduced to relevant part (--skip-* flags).
Added split/merge functions to fasta.py file, r_rna, nc_rna, nc_rna-regions will use the same function and approach - i measured similar performance benefit but thats for another PR.
Don't mind me while on vacation :D, enjoy your time off.