[R-sig-Debian] Debian packaging and openblas related crash when profiling in R

luke-tierney at uiowa.edu luke-tierney at uiowa.edu
Fri Dec 14 17:30:04 CET 2012


On Unix-like systems profiling uses the profile timer, which works via
signals. If a threaded C-level library isn't programmed to be sure to
ignore signals it isn't using itself then the signal will go to the
wrong thread and the handler and the main R process start messing in
the same memory with out synchronization. I believe we should be able
to make sure that the handler only does it's work when called from the
main R thread (maybe just re-signaling to the main thread if the
signal goes to the wrong one). The few other signals we use could
probably use this as well. I'll look into this sometime if no one else
gets there first; there is a lot of fine print involved in
signal/threads interaction so it may take a while.

Of course the current mechanism of profiling on Unix doesn't really
make senss for multi-threaded programs as it is based on process user
time (I believe); for threaded programs we sould want something based
on clock time. Not sure what the options are these days, but worth
looking into.

Windows uses a different mechnism for profiling so this is not likely
to be related to another thread on Windows/Rprof issues.

Best,

luke

On Fri, 14 Dec 2012, Dirk Eddelbuettel wrote:

>
> Paul,
>
> On 14 December 2012 at 01:17, Paul Johnson wrote:
> | Dirk!
> |
> | Correct as usual!
>
> [...]
>
> | Here's the evidence you are right.
> |
> | Before starting R, restrict openblas's use of threads in the environment
> |
> | $ export GOTO_NUM_THREADS=1
> |
> | After that, HAPPY profiling in R!
>
> Right.
>
> If one has tried multithreading before as I have with (so-far unsuccessful)
> endeavours to get OpenMP into one particular package (while maintaining RNG
> outcomes / reproducibility) then those stack error look eerily familiar.
>
> All very frustrating because "it all just works" with one thread.
>
> And that is all R can handle, so if you multithread, set proper mutexes.  And
> for profiling that very logic seems to require turning multithreading off.
>
> Cheers, Dirk
>
>

-- 
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:   luke-tierney at uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



More information about the R-SIG-Debian mailing list