[R-pkg-devel] Too many cores used in examples (not caused by data.table)
Ivan Krylov
kry|ov@r00t @end|ng |rom gm@||@com
Fri Oct 20 15:54:37 CEST 2023
В Thu, 19 Oct 2023 05:57:54 +0000
"Helske, Jouni" <jouni.helske using jyu.fi> пишет:
> But I just realised that bssm uses Armadillo via RcppArmadillo, which
> uses OpenMP by default for some elementwise operations. So, I wonder
> if that could be the culprit?
I wasn't able to reproduce the NOTE either, despite manually setting
the environment variable
_R_CHECK_EXAMPLE_TIMING_CPU_TO_ELAPSED_THRESHOLD=2 before running R CMD
check, but I think I can see the code using OpenMP. Here's what I did:
0. Temporarily lower the system protections against capturing
performance traces of potentially sensitive parts:
echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid
(Set it back to 3 after you're done.)
1. Run the following command with the development version of the
package installed:
env OPENBLAS_NUM_THREADS=1 \
perf record --call-graph drawf,4096 \
R -e 'library(bssm); system.time(replicate(100, example(exchange)))'
OPENBLAS_NUM_THREADS=1 will prevent OpenBLAS from spawning worker
threads if you have it installed. (A different BLAS may need different
environment variables.)
2. Run `perf report` and browse collected call stack information.
The call stacks are hard to navigate, but I think they are not pointing
towards Armadillo. At least, setting ARMA_OPENMP_THREADS=1 doesn't
help, but setting OMP_THREAD_LIMIT=1 does.
--
Best regards,
Ivan
More information about the R-package-devel
mailing list