Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stacks sometimes show profvis #130

Closed
wch opened this issue Mar 12, 2021 · 4 comments · Fixed by #172
Closed

Stacks sometimes show profvis #130

wch opened this issue Mar 12, 2021 · 4 comments · Fixed by #172
Labels

Comments

@wch
Copy link
Member

wch commented Mar 12, 2021

I just rebuild the docs, and noticed that profvis and the tryCatch stuff shows up in many of the stacks.

image

https://rstudio.github.io/profvis/examples.html#example-2

─ Session info ───────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 4.0.3 (2020-10-10)
 os       macOS Big Sur 10.16         
 system   x86_64, darwin17.0          
 ui       X11                         
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       America/Chicago             
 date     2021-03-12                  

─ Packages ───────────────────────────────────────────────────────────────────
 package     * version    date       lib source                          
 assertthat    0.2.1      2019-03-21 [1] CRAN (R 4.0.0)                  
 cli           2.3.0      2021-01-31 [1] CRAN (R 4.0.2)                  
 digest        0.6.27     2020-10-24 [1] CRAN (R 4.0.2)                  
 glue          1.4.2      2020-08-27 [1] CRAN (R 4.0.2)                  
 htmltools     0.5.1.1    2021-01-22 [1] CRAN (R 4.0.2)                  
 htmlwidgets   1.5.3      2020-12-10 [1] CRAN (R 4.0.2)                  
 magrittr      2.0.1      2020-11-17 [1] CRAN (R 4.0.2)                  
 profvis     * 0.3.7.9000 2021-02-05 [1] Github (rstudio/profvis@2aa2c5a)
 purrr         0.3.4      2020-04-17 [1] CRAN (R 4.0.0)                  
 rlang         0.4.10     2020-12-30 [1] CRAN (R 4.0.2)                  
 sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 4.0.0)                  
 stringi       1.5.3      2020-09-09 [1] CRAN (R 4.0.2)                  
 stringr       1.4.0      2019-02-10 [1] CRAN (R 4.0.0)                  
 withr         2.4.1      2021-01-26 [1] CRAN (R 4.0.2)                  
@hadley
Copy link
Member

hadley commented Aug 21, 2024

Updated link: https://r-lib.github.io/profvis/examples.html#example-2

I still see the problem when running locally, which surprises me because I thought the callstack simplification would have fixed this problem. This will need a bit more exploration

profvis::profvis({
  data <- data.frame(value = runif(5e4))

  data$sum[1] <- data$value[1]
  for (i in seq(2, nrow(data))) {
    data$sum[i] <- data$sum[i-1] + data$value[i]
  }
})

@hadley hadley added the bug label Aug 21, 2024
@hadley
Copy link
Member

hadley commented Aug 22, 2024

Actually probably related to suffix stripping.

@hadley
Copy link
Member

hadley commented Aug 22, 2024

The problem is that rprof_current_suffix_linear() isn't picking up any of the calls added to the stack by with_profvis_handlers(). This might be a @lionel- problem unless I can come up with a simpler work around.

Looking at the call stack inside rprof_current_suffix_linear() suggests the problem — we're not evaluating it in exactly the right place.

     ▆
  1. ├─profvis::profvis(...)
  2. │ ├─profvis:::with_profvis_handlers(...) at profvis/R/profvis.R:198:5
  3. │ │ └─base::tryCatch(...) at profvis/R/profvis.R:246:3
  4. │ │   └─base (local) tryCatchList(expr, classes, parentenv, handlers)
  5. │ │     ├─base (local) tryCatchOne(...)
  6. │ │     │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
  7. │ │     └─base (local) tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  8. │ │       └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
  9. │ │         └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 10. │ └─profvis:::rprof_current_suffix(env, simplify) at profvis/R/profvis.R:199:7
 11. └─profvis (local) `<fn>`() at profvis/R/rprof.R:75:5
 12.   └─profvis:::rprof_current_suffix_linear(...) at profvis/R/rprof.R:73:19

@hadley
Copy link
Member

hadley commented Aug 22, 2024

I wonder if we could record the call stacks just once, rather than having to do it every time. The only downside would be if folks are nesting profvis inside other calls, but that's probably rare?

hadley added a commit that referenced this issue Sep 17, 2024
hadley added a commit that referenced this issue Sep 17, 2024
Radically simpler approach to stripping irrelevant stack. Fixes #130
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants