Jointprof
Joint profiling of native and R code
Install / Use
/learn @r-prof/JointprofREADME
jointprof
The goal of jointprof is to assist profiling R packages that include native code (C++, C, Fortran, ...). It collects profiling output simultaneously using Rprof and gperftools and provides a unified view of profiling data.
See the guide for a more detailed overview, or take a look at the internals document if you're curious.
Installation
Ubuntu
Other Linux distributions may work if you install the right system dependencies (let me know which!).
-
Install system dependencies:
sudo apt install \ libgoogle-perftools-dev \ libprotoc-dev libprotobuf-dev protobuf-compiler \ golang-go \ graphviz -
Install
pprof:go get github.com/google/pprof -
Install the package:
# install.packages("remotes") remotes::install_github("r-prof/jointprof")
OS X
-
Install system dependencies:
brew install graphviz -
Install
gperftools(currently from a branch, pull request pending):git clone https://github.com/krlmlr/gperftools.git -b f-export-stack cd gperftools ./autogen.sh ./configure make sudo make install cd .. -
Install
pprof:go get github.com/google/pprof -
Install the package:
# install.packages("remotes") remotes::install_github("r-prof/jointprof")
Other OS
Windows and Solaris are not supported.
Usage
library(jointprof)
target_file <- "Rprof.out"
# Collect profile data
start_profiler(target_file)
## code to be profiled
stop_profiler()
# Analyze profile data
summaryRprof(target_file)
profvis::profvis(prof_input = target_file)
proftools::readProfileData(target_file)
prof.tree::prof.tree(target_file)
# Convert to pprof format and analyze
pprof_target_file <- "Rprof.pb.gz"
profile_data <- profile::read_rprof(target_file)
profile::write_rprof(profile_data, pprof_target_file)
system2(
find_pprof(),
c(
"-http",
"localhost:8080",
shQuote(pprof_target_file)
)
)
Acknowledgment
This project is being realized with financial support from the
<img src="https://www.r-consortium.org/wp-content/uploads/sites/13/2016/09/RConsortium_Horizontal_Pantone.png" width="400">