[R] Rprof and system

Benjamin Tyner btyner at gmail.com
Wed Aug 12 02:41:21 CEST 2015


I have an R script which invokes WriteXLS() (from the package of the
same name) which as you may know, calls perl via system(). I've noticed
that when I enable profiling using Rprof(), when the script gets to the
part where perl is called, it gets "stuck": it just sits there using
99-100% CPU and around 10% of the RAM, and the perl command does not
even show up as a running process under 'top'. While it is churning
away, new profiling results continue to be written to the profiling file
(at which point the entries are all "system" / "WriteXLS").  I have also
noticed this behavior with other system() calls; not just perl. I've
also tried pipe(cmd, open = "r") as an alternative to system(cmd) and
the result is the same. I have tried in interactive as well as
non-interactive mode, and the issue occurs in both modes although seems
to be more common in the latter.

So, I'm wondering if perhaps Rprof() + system() not a recommended
combination ? I did notice from ?Rprof that "the profiler interrupts R
asynchronously"; though I do not know what that means, perhaps that is
somehow relevant? This is running on R version 3.2.1 under linux (RHEL6).

Any suggestions would be greatly appreciated.


More information about the R-help mailing list