-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Description
Description
CRAN's submission policies at https://cran.r-project.org/web/packages/policies.html include the following guidance
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.
Currently, most of {lightgbm}
's examples and tests do not explicitly set the number of threads to use, which means LightGBM defaults to using whatever the result of omp_get_num_threads()
is.
LightGBM/include/LightGBM/utils/openmp_wrapper.h
Lines 30 to 34 in 60e72d5
if (num_threads > 0) { | |
omp_set_num_threads(num_threads); | |
} else { | |
omp_set_num_threads(default_omp_num_threads); | |
} |
Work to be done
To ensure that {lightgbm}
is always respectful of the CRAN check farm, all of its examples and tests should be changed to default to using 2 threads when run on CRAN.
Similar to the work done for #4862
LightGBM/R-package/tests/testthat/test_lgb.Booster.R
Lines 1 to 3 in 820ae7e
VERBOSITY <- as.integer( | |
Sys.getenv("LIGHTGBM_TEST_VERBOSITY", "-1") | |
) |
this should be done in a way that allows LightGBM's CI to override that behavior and use all available CPUs in its CI environments (which might sometimes be more than 2).
NUM_THREADS <- as.integer(
Sys.getenv("LGB_NUM_THREADS", "2")
)
References
Opened as a result of #4972 (comment).