[R-pkg-devel] Profiling C++ code in R packages on Windows

Martin R. Smith m@rt|n@@m|th @end|ng |rom durh@m@@c@uk
Mon Feb 28 16:29:04 CET 2022


Dear all,

I've been struggling to profile C++ code within an R package I'm writing on
Windows 10.

After finding various excellent online guides, I'm building the package
with g++ 8.3.0 using -Og -g -fpic -mstackrealign, and omitting the -s flag
when linking the DLL. AMD µprof is showing time spent within
[~]/R/win-library/4.1/00LOCK-MYPACKAGE/00new/MYPACKAGE/libs/x64/MYPACKAGE.dll,
but when I double click for a line-by-line profile I see "Binary file []
missing! Unable to show source view...". I have a similar issue if I try
using Very Sleepy instead.

I wonder whether anyone would be able to suggest why my profiler can't
identify functions, or find the package source?



My ideas so far:
-- I noticed that the source files constructed when installing the package
are no longer present: no .o or tmp.def files are evident in my package's
"src" directory. But I can't work out how to make these files persist
beyond the compilation process, in a manner that a profiler can locate
them. I've tried:

* Installing using devtools::install(keep.source = TRUE)
* Including the  --with-keep.source option when installing the package via
R CMD INSTALL (within RStudio)

-- The profiler is identifying the dll in a temporary 00LOCK- folder,
rather than its final location in win-library/4.1/MYPACAKGE/MYPACKAGE.dll.
This 00LOCK folder only exists whilst the package is being installed. Could
the DLL contain links to this folder that are not updated when the package
files are moved to their final home?

Many thanks,

Martin Smith

--

*Dr. Martin R. Smith*
Associate Professor in Palaeontology
Durham University
Department of Earth Sciences
Mountjoy Site, South Road, Durham, DH1 3LE United Kingdom

*M*: +44 (0)774 353 7510
*E*: martin.smith using durham.ac.uk
*Zoom room*: durhamuniversity.zoom.us/my/smith

smithlabdurham.github.io
twitter.com/PalaeoSmith

My working days are Monday–Thursday.

The information in this e-mail and any attachments is co...{{dropped:13}}



More information about the R-package-devel mailing list