-
Notifications
You must be signed in to change notification settings - Fork 14
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
RC 1.0.5 #251
RC 1.0.5 #251
Conversation
Your CPU time problems are likely caused by |
Hello @aitap! Thanks for looking into this! I tried that a while ago a7458a3 I don't think they are the issue as Unless I need to do that in addition to the data.table stuff. let me try that |
I'm sorry it didn't help. I see you're using library(text2vec) and only
then options("text2vec.mc.cores" = 1). This is the most careful way
(text2vec:::.onLoad resets the option!); if text2vec.mc.cores was the
culprit, your fix would have worked.
Another option I tried was to patch parallel::detectCores() to always
return a large number and then run R CMD check on your package with the
_R_CHECK_EXAMPLE_TIMING_CPU_TO_ELAPSED_THRESHOLD_=2 environment
variable and the --timings flag set. I couldn't reproduce it either. I
do get CPU time ~1.3 times elapsed time for the step_dummy_hash
example, but (1) only because I have parallel OpenBLAS installed and
(2) 1.3 times is too low to trigger the NOTE.
|
I've set a breakpoint on pthread_create in gdb and ran
example(step_dummy_hash). The breakpoint fired multiple times; the
unexpected hits were in rsparse's omp_thread_count() [1] where it
eventually set options(rsparse_omp_threads) [2] to the number of
logical processors on my virtual machine.
I think that rsparse:::.onLoad gets to run (and decide to use the whole
CPU) before you set OMP_THREAD_LIMIT because rlang::is_installed calls
requireNamespace. Putting the Sys.setenv() call above the call to
rlang::is_installed() should circumvent the problem.
[1]
https://github.com/rexyai/rsparse/blob/873db8474c09e6974404e65868a712af8d834fb0/src/utils.cpp#L80-L91
[2]
https://github.com/rexyai/rsparse/blob/873db8474c09e6974404e65868a712af8d834fb0/R/zzz.R#L27
|
@aitap Thank you so much for looking into this! Would you be able to teach me what you did to gain those insights? I'm fine if you don't, you already helped me so much! |
My first idea was that if something takes too much CPU time, it ought to show up in the CPU profiler. Writing R Extensions mentions a few profiling techniques. I've heard good things about Intel's VTune profiler (on both GNU/Linux and Windows) and Very Sleepy on Windows. The section on profiling in Algorithmica is a bit terse but contains useful pointers. I'm using I'm using an accelerated BLAS that can start threads on its own, so I was ready to blame OpenBLAS for the threads, but even with the environment variable If threads do evidently consume extra CPU time, perhaps some information could be gained by seeing who creates them? The OpenMP specification is not 100% precise on this, but it makes sense for a program to start new threads when it encounters a The |
This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue. |
to close #250