[R] R_DirtyImage and Rprof
Benjamin Tyner
btyner at gmail.com
Thu May 12 04:39:21 CEST 2016
Hello,
I have some code which was running in interactive mode while Rprof(...,
line.profiling = TRUE). Near the end of my script, it opens up a
pipe(..., open = "w") to a perl script, and at that point the execution
gets stuck using 100% cpu.
(The perl script itself never showed up in pstree, as far as I can tell).
I did a "tail -f" on the file being written to by Rprof, and it was
reporting "sys.save.image" over and over, and in fact an ".RData" file
appeared when I had not asked for one, and I was able to load it later.
This got me curious, as nowhere in my code do I directly use that
function. Looking through the source code for R, it appears that
"sys.save.image" is called whenever an R_DirtyImage condition is triggered.
This was using R version 3.2.2 under RHEL. My efforts to create a
reproducible example of this behavior have thus far been unsuccessful.
My questions: is there any documentation for R_DirtyImage, and how
plausible is it that the R_DirtyImage condition was triggered by
something Rprof did? The reason for my conjecture is that
sys.save.image() calls closeAllConnections(), which I imagine might have
interfered with the pipe that was open for writing, thus causing the
stuck execution at that point.
If so, any advice for avoiding the R_DirtyImage condition while profiling?
If not, any conjectures for what might actually be going on? For what
it's worth, I have observed a similar situation when using Rprof +
system() instead of pipe(); for example:
https://stat.ethz.ch/pipermail/r-help/2015-August/431286.html
Regards
Ben
More information about the R-help
mailing list