Repository navigation
fix: limit mafft/FastTree threads to the cpus allocated to the job - #138
Merged
Merged
Conversation
merge_msa ran mafft with --thread -1, which counts the physical cores of
the machine and ignores the cpus slurm (or any scheduler) allocated. With
--parallel up to 6 taxonomic levels each started such a mafft, so hog_big
could run 6 x ncores threads on 4 allocated cpus. OpenMP builds of
FastTree likewise use all cores unless OMP_NUM_THREADS is set.
fastoma-infer-subhogs gets a --threads option (default: the cpus in the
process' affinity mask) and Nextflow passes ${task.cpus}. The threads form
one shared budget: the level thread pool has that many workers, and every
mafft/FastTree call reserves between 1 and a fair share
(total / active levels, capped at 8 resp. 4) of the free threads for the
duration of the subprocess only. Near the leaves each call gets one
thread; near the root the few remaining large alignments get the rest.
Threads are never held while waiting for more, so this cannot deadlock.
mafft and FastTree output was verified byte-identical across 1-8 threads.
The hardcoded cpus of hog_big moved to conf/base.config so it can be
overridden there.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
alpae
commented
Dec 1, 2026
alpae
commented
Dec 1, 2026
alpae
commented
Dec 1, 2026
alpae
commented
Dec 1, 2026
alpae
commented
Dec 1, 2026
alpae
commented
Dec 1, 2026
alpae
commented
Dec 1, 2026
- hog_big memory grows with its cpus instead of capping the number of levels inferred in parallel. A level is only submitted once its children are done and pickled, so the levels running at the same time hold disjoint genes and their data is bounded by the rootHOG size. Only the per-process overhead of mafft/FastTree grows with the cpus, covered by 512 MB per cpu. - When a level fails, the queued levels are cancelled (shutdown(cancel_futures=True)) instead of all running first. - available_cpus() also respects the cgroup cpu quota (cgroup v1 and v2), so the default of --threads is right under docker --cpus or Kubernetes limits. - FastTree reserves a single thread unless the binary is an OpenMP build (detected once from its -expert header). - Leaf levels run no external tool and no longer count as budget workers, so they don't shrink the share of the inner levels. - threads(max_threads=0) reserves 1 thread instead of the whole budget. - handle_fragment_msa called infer_gene_tree with 3 arguments (unused code path). The CHANGELOG lists --threads and documents that hog_big now requests 4 cpus via withName, which overrides generic and withLabel cpus settings.
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.
merge_msa ran mafft with --thread -1, which counts the physical cores of
the machine and ignores the cpus slurm (or any scheduler) allocated. With
--parallel up to 6 taxonomic levels each started such a mafft, so hog_big
could run 6 x ncores threads on 4 allocated cpus. OpenMP builds of
FastTree likewise use all cores unless OMP_NUM_THREADS is set.
fastoma-infer-subhogs gets a --threads option (default: the cpus in the
process' affinity mask) and Nextflow passes ${task.cpus}. The threads form
one shared budget: the level thread pool has that many workers, and every
mafft/FastTree call reserves between 1 and a fair share
(total / active levels, capped at 8 resp. 4) of the free threads for the
duration of the subprocess only. Near the leaves each call gets one
thread; near the root the few remaining large alignments get the rest.
Threads are never held while waiting for more, so this cannot deadlock.
mafft and FastTree output was verified byte-identical across 1-8 threads.
The hardcoded cpus of hog_big moved to conf/base.config so it can be
overridden there.
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com