Git Product home page Git Product logo

jointprof's People

Contributors

0intro avatar 38elements avatar aalexand avatar anacrolix avatar atdt avatar atheriel avatar ghemawat avatar gmarin13 avatar hk-cho avatar hyangah avatar ianlancetaylor avatar josef-jelinek avatar josharian avatar krlmlr avatar nolanmar511 avatar prattmic avatar rauls5382 avatar rsc avatar s-kanev avatar sajmani avatar simonque avatar spiermar avatar tamird avatar tdewolff avatar tippjammer avatar vcabbage avatar vlankhaar avatar wade-k avatar walken-google avatar zchee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

jointprof's Issues

Different handling of SIGPROF in gperftools >= 2.5

The code in README.md only works for gperftools <= 2.4. It seems that gperftools >= 2.5 installs a signal handler once when the library is loaded, while gperftools <= 2.4 install a signal handler when the profiler is started, and remove it afterwards.

Error: package or namespace load failed for ‘jointprof’ in dyn.load(file, DLLpath = DLLpath, ...):

Error: package or namespace load failed for ‘jointprof’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/00LOCK-jointprof/00new/jointprof/libs/jointprof.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/00LOCK-jointprof/00new/jointprof/libs/jointprof.so, 6): Symbol not found: __Z24GetStackTraceWithContextPPviiPKv
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/00LOCK-jointprof/00new/jointprof/libs/jointprof.so
Expected in: flat namespace
in /Library/Frameworks/R.framework/Versions/4.0/Resources/library/00LOCK-jointprof/00new/jointprof/libs/jointprof.so
Error: loading failed
Execution halted
ERROR: loading failed

  • removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/jointprof’
    Warning message:
    In i.p(...) :
    installation of package ‘/var/folders/mq/303j9hds3sd14mdf7d50tb7r0000gn/T//RtmpuSikjS/file2bd27243e666/jointprof_0.0.1.9001.tar.gz’ had non-zero exit status

Reading .prof files created by gperftools

currently requires pprof, a Go program. Need to do one of the following:

  1. Parse the textual output of pprof
  2. Call Go from R via cgo
  3. Rebuild the parser for the profiler output in R
  4. Build a reader for the profiler data

A first implementation will focus on the first option and require a compatible version of pprof that can be found by the package.

Merge R and native call stacks

  • distinguish R sources from packages' sources
    • R: usually starts with src/main or src/library
    • packages: usually src/ without subdirectory
  • interleaved stacks R -> native -> R -> native ...
    • need to find entry point(s) native -> R

API improvements

  • gprofiler::with_profiler()
  • gprofiler::run_pprof() via processx

Compatibility with pkgload::load_all()

Needs proper deinitialization (or not do work on reinitialization):

Loading jointprof
Disabling profiler because signal 27 handler is already in use.

Windows portability

Windows is highly unlikely to work with gperftools. Need to:

  • Capture stack trace
  • Write /proc/self maps (how?)
  • Symbolize

Perhaps VerySleepy can be ported?

Release jointprof 1.0.0

Prepare for release:

  • Check that description is informative
  • Check licensing of included files
  • usethis::use_cran_comments()
  • devtools::check()
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • rhub::check(platform = 'ubuntu-rchk')
  • rhub::check_with_sanitizers()
  • Polish pkgdown reference index
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('major')
  • Update cran-comments.md
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • Update install instructions in README
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

OS X compatibility

seems to require PKG_LIBS = -ltcmalloc -lprofiler (in that order). Need to double-check if there are any adverse side effects: gperftools/gperftools#948 (comment).

Installation:

  • pprof via Go
  • gperftools via brew
  • ...?

Implement Travis test, Travis debugging is already enabled for this repo.

R 3.5.0 compatibility

I'm seeing

Disabling profiler because signal 27 handler is already in use.

on Travis CI, still using R 3.4.4 locally.

Reimplement relevant parts of gperftools profiler

because the stock implementation rearranges and aggregates samples. Reuse code, luckily stacktrace.h is public.

Shipping a modified version of libprofiler.so in an R package is an alternative, but:

  • reimplementing doesn't seem to be too difficult
  • the target file format is very simple to write
  • we have more control with our own implementation
  • we might even be able to support Windows
  • we get rid of that message to stderr

Steps:

  • write header
  • establish signal handler
  • record stack trace, write to file immediately (CpuProfiler::prof_handler())
  • daisy-chain with R's signal handler
  • when finishing, write trailer and dump proc map (DumpProcSelfMaps())

Prepare CRAN release

  • org website with pointers
    • installation instructions
  • split pprof package
    • installation of binary files: src/install.libs.R in R-exts
  • brush up documentation
  • get rid of check warnings

Read incomplete files

  • allow incomplete files
  • merge records read from incomplete files
  • incremental reading

Profiling parallel code

  • multiprocess
    • only profile main process
  • multithreaded
    • by definition only R -> C, depends on the capabilities of the profiler library

Decide what to do with write_flat_ds()

The package currently contains a write_flat_ds() function (in debug.R) that is not exported, used anywhere else in the package, or used in any tests. In addition, this function is the sole user of the readr dependency, although that could probably be moved to Suggests or replaced with utils::write.csv().

I think there are a few possible ways to deal with this (currently) dead code:

  • Remove it.
  • Use it in the test suite; or
  • Move it to the profile package.

macOS compatibility

Upstream issue: gperftools/gperftools#948.

The necessary patch to gperftools is in upstream master but not yet on Debian: gperftools/gperftools#1187. It will take some time to appear on Ubuntu anyway (where it is optional), and can already be installed on Homebrew (using HEAD) where it is mandatory.

Aiming at implementing compatibility with both versions, driven by the configure script.

Profiling R

What happens if a substantial amount of time is spent in internal R routines (native code), such as string conversion? Can we use joint profiling to help profiling R itself?

CC @radfordneal.

C code profiling results of `coxph` in `survival` package does not show up in the final result

I'm running Ubuntu 20.04.1 LTS with R 3.6.3 installed. I tried to profile the C code in coxph function of survival using the following commands (I used coxed solely to increase the running time of coxph):

library(survival)
library(jointprof)
library(coxed)

simdata = sim.survdata(N = 10000)

joint_pprof(coxph(Surv(y, failed) ~ X1+X2+X3, data=simdata$data))

The following the graph I got as a result. Before profiling, I recompiled the whole survival package with install.packages("survival", type="source", INSTALL_opts="--with-keep.source") and CFLAGS set to -g -O0 -mtune=native. It's clear that the C code profiling results are missing.
image
After looking into some intermediate results (the separate pprofile and rprofile files), it is clear that the C code was indeed profiled and the results were stored. However, in the rprofile file:

...
#File 3: /tmp/Rtmp5g7EGI/R.INSTALL235a67daae2bd/survival/R/coxph.fit.R
"aperm.default" "aperm" "apply" 3#55 "coxph.fit" 2#555 "coxph" "comingle_rprof" "comingle_pprof" "joint_pprof" 
"%in%" 3#55 "FUN" "apply" 3#55 "coxph.fit" 2#555 "coxph" "comingle_rprof" "comingle_pprof" "joint_pprof" 
"%in%" 3#55 "FUN" "apply" 3#55 "coxph.fit" 2#555 "coxph" "comingle_rprof" "comingle_pprof" "joint_pprof" 
"%in%" 3#55 "FUN" "apply" 3#55 "coxph.fit" 2#555 "coxph" "comingle_rprof" "comingle_pprof" "joint_pprof" 
3#59 "coxph.fit" 2#555 "coxph" "comingle_rprof" "comingle_pprof" "joint_pprof" 
3#59 "coxph.fit" 2#555 "coxph" "comingle_rprof" "comingle_pprof" "joint_pprof" 
3#59 "coxph.fit" 2#555 "coxph" "comingle_rprof" "comingle_pprof" "joint_pprof" 
3#59 "coxph.fit" 2#555 "coxph" "comingle_rprof" "comingle_pprof" "joint_pprof" 
3#59 "coxph.fit" 2#555 "coxph" "comingle_rprof" "comingle_pprof" "joint_pprof" 
...

In line 59 of coxph.fit.R:

    coxfit <- .Call(Ccoxfit6, ...

.Call is called but the function name is not registered in the rprofile result. This is perhaps the reason why the C code profiling results did not show up in the graph, because jointprof need to know where .Call is called inside R to locate the position where the two separate profiling results should be combined.
As I am not very familiar with profiling in general, I could not go any further on this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.