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

WISH: parallelly::availableCores() instead of parallel::detectCores() #101

Open
HenrikBengtsson opened this issue May 5, 2022 · 1 comment

Comments

@HenrikBengtsson
Copy link

(disclaim: I'm the author) To minimize the risk of overusing CPUs on multi-tenant and multi-process machines, but also to work in more environments, please consider changing:

get_cores <-function(num_cores){
if(is.null(num_cores)) {
parallel::detectCores()-1
} else {
min(num_cores, parallel::detectCores()-1)
}
}

to

 get_cores <-function(num_cores){  
   min(c(parallelly::availableCores(omit = 1), num_cores))
 }

This also has the benefit of working on single-core hosts, where detectCores() == 1, e.g. free RStudio Cloud accounts, some k8s/container setups, etc. For more arguments, see https://parallelly.futureverse.org/#availablecores-vs-paralleldetectcores.

@mitokic
Copy link
Collaborator

mitokic commented May 6, 2022

Hey Henrik, thanks for reaching out. I'll look more into this and incorporate into package soon. Our main focus right now is to build out new parallel compute options like spark.

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

No branches or pull requests

2 participants