xrprof icon indicating copy to clipboard operation
xrprof copied to clipboard

xrprof with Rcpp: no info on the C++ side

Open aalucaci opened this issue 3 years ago • 4 comments

Hello, I built xrprof (by the way, a note on the minimum gcc compiler version would have helped - with old versions the Makefile does not work as it is), install it locally and tried with an R script calling an Rcpp function from a private package.

Unfortunately, although simple printout tells me that most part of the time is spent on the C++ side, the flame graph only shows the R functions, nothing on the C++ side.

You mention that sudo might be needed - not sure what you mean by this. I have no sudo rights on the machine I'm working on. But I would have expected some kind of error if this would have been an issue.

Could you give me a hint on what do I do wrong?

Or better, would it be possible to show us an Rcpp example, where the flame graph would show the C++ functions also?

Thank you for your time, Angela

aalucaci avatar Feb 02 '21 08:02 aalucaci

It's a bit hard to know what's happening here without you showing how you are calling xrprof, but keep in mind that it won't show the C/C++ code by default -- you have to pass the -m flag:

$ Rscript myscript.R &
# sudo may be required.
$ xrprof -m -p <PID> -F 50 > Rprof.out

atheriel avatar Feb 02 '21 18:02 atheriel

by the way, a note on the minimum gcc compiler version would have helped - with old versions the Makefile does not work as it is

This I can probably fix -- what was the error you saw/fixed?

atheriel avatar Feb 02 '21 18:02 atheriel

Hello, thanks a lot for your time.

With gcc 4.8.5 (I know, too old, don't ask...), I received the following errors:

src/locate.c:130:3: error: 'for' loop initial declarations are only allowed in C99 mode src/process.h:8:1: error: unknown type name 'pid_t' src/rdefs.h:134:3: error unknown type name 'sigjmp_buf'

The solution was:

  • Makefile: add -std=gnu99 to CFLAGS
  • process.h, line 7: #include <sys/types.h>

All these are not necessary with a newer compiler version, it just took me a while to understand this. Maybe this would help others.

Your advice about passing the -m flag helped me, now I see C++ stuff, I still have to learn to read it, but that's for me to do. Maybe you could add the hint to the Usage section on the main page?

Once again, thank for your help, I appreciate it.

Kind regards, Angela

aalucaci avatar Feb 02 '21 21:02 aalucaci

now I see C++ stuff, I still have to learn to read it, but that's for me to do.

You probably have "mangled" names that you will want to convert back to readable strings -- try running the profile output through c++filt (likely installed on your system).

I'll try to work on the other issues as well.

atheriel avatar Feb 02 '21 21:02 atheriel