[R] Number of Cores limited to two in CRAN

Henrik Bengtsson henr|k@bengt@@on @end|ng |rom gm@||@com
Sun Jul 2 10:33:34 CEST 2023

Short answer: You don't want to override that limit in your R package.
Don't do it.

Long answer: You'll find the reason for this in the 'CRAN Repository
Policy' (https://cran.r-project.org/web/packages/policies.html).
Specifically, the following passage:

"Checking the package should take as little CPU time as possible, as
the CRAN check farm is a very limited resource and there are thousands
of packages. Long-running tests and vignette code can be made optional
for checking, but do ensure that the checks that are left do exercise
all the features of the package.

**If running a package uses multiple threads/cores it must never use
more than two simultaneously: the check farm is a shared resource and
will typically be running many checks simultaneously.**

Examples should run for no more than a few seconds each: they are
intended to exemplify to the would-be user how to use the functions in
the package."

Basically, you can use two cores to demonstrate or validate (e.g. in
package tests) that your code *can* run in parallel, but you must not
use more than that to demonstrate that your code can "run super fast".

Even-longer answer: See my blog post 'Please Avoid detectCores() in
your R Packages' (https://www.jottr.org/2022/12/05/avoid-detectcores/)
from 2022-12-05 for even more reasons.


On Sun, Jul 2, 2023 at 9:55 AM Ravi Varadhan via R-help
<r-help using r-project.org> wrote:
> This is the specific error messsage from R CMD check --as-cran
> Error in .check_ncores(length(names)) : 16 simultaneous processes spawned
>   Calls: prepost -> makeCluster -> makePSOCKcluster -> .check_ncores
>   Execution halted
> Thanks,
> Ravi
> ________________________________
> From: Ravi Varadhan
> Sent: Saturday, July 1, 2023 1:15 PM
> To: R-Help <r-help using r-project.org>
> Subject: Number of Cores limited to two in CRAN
> Hi,
> I am developing a package where I would like to utilize multiple cores for parallel computing.  However, I get an error message when I run R CMD check --as-cran.
> I read that CRAN limits the number of cores to 2.  Is this correct? Is there any way to overcome this limitation?
> Thank you,
> Ravi
>         [[alternative HTML version deleted]]
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list