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

Optionally auto-scale the number of threads used for alignment and tree building #222

Merged
merged 4 commits into from
Sep 27, 2018

Conversation

tsibley
Copy link
Member

@tsibley tsibley commented Sep 20, 2018

Uses all the available CPU cores by default instead of just 2. It is still possible to limit the number of threads to a certain number using the --nthreads options to "align" and "tree".

Auto-scaling by default is particularly nice because it means the same command invocations in Snakefile can make the most of the system they're run on, whether that's a laptop or the cluster or a beefy AWS instance.

This PR builds off PR #217 (the command-architecture branch), so should wait to merge until that is merged.

@tsibley
Copy link
Member Author

tsibley commented Sep 25, 2018

@huddlej If you could take a look at this, I'd appreciate it! I've been asking @trvrb a lot to do review, so I figured I should branch out. If you don't have time, I can ask someone else.

@tsibley tsibley closed this Sep 25, 2018
@tsibley tsibley changed the base branch from command-architecture to master September 25, 2018 19:28
@tsibley tsibley reopened this Sep 25, 2018
If the allowed values for --method are updated without the case-by-case
conditional being updated to match, an error will now be thrown instead
of the command running with the wrong tree builder (FastTree).  This
type of defensive or comprehensive check is a common best practice.
It's leftover from when "refine" (née "treetime") and "tree" were the
same command, before commit 6832839.
By default, FastTree with OpenMP support uses all available cores.  This
mismatches the other tree builders we use and the interface presented by
the "tree" command (which allows a specific number of threads to be
set).
@huddlej
Copy link
Contributor

huddlej commented Sep 26, 2018

For posterity, @tsibley and I talked about this yesterday with respect to how to make it work on OS X and Windows environments that don't have the same "affinity state" methods. We agreed on two complementary approaches: to default to cpu_count() from the multiprocessing module on other OSs and to explore the threads functionality of Snakemake rules as a way to externally manage threads per job.

…ee building

Passing "--nthreads auto" to the "align" or "tree" commands will use all
the available CPU cores.  The default is reduced from 2 to 1, which is
the only safe assumption.

Auto-scaling is not the default because it's not necessarily reasonable
to assume that all cores should be used without more information about
the system's workload.  For example, someone running two simple `augur
tree` commands may not reasonably expect them to conflict with each
other, but they would with auto-scaling enabled by default.  Parallelism
requires co-operation and thus an explicit opt-in.
@tsibley
Copy link
Member Author

tsibley commented Sep 26, 2018

Re: our discussion, I've just re-pushed this changing the default and implementing a better fallback cascade for CPU count.

@tsibley tsibley changed the title Auto-scale the number of threads used for alignment and tree building Optionally auto-scale the number of threads used for alignment and tree building Sep 26, 2018
Copy link
Contributor

@huddlej huddlej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! This works for me and I love the use of "auto" for explicitly requesting all cores.

@tsibley
Copy link
Member Author

tsibley commented Sep 27, 2018

Thanks for the review!

@tsibley tsibley merged commit 40040eb into master Sep 27, 2018
@tsibley tsibley deleted the auto-scale-threads branch September 27, 2018 18:52
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.

None yet

2 participants