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

Traceback is a large object when medium data is passed to args #185

Closed
wlandau opened this issue Mar 14, 2021 · 0 comments
Closed

Traceback is a large object when medium data is passed to args #185

wlandau opened this issue Mar 14, 2021 · 0 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@wlandau
Copy link

wlandau commented Mar 14, 2021

When I pass medium-sized data to args and my function hits an error, the call stack is an unexpectedly large object, and there is a time delay before the whole call ends.

library(callr)
suppressPackageStartupMessages(library(pryr))
print(packageDescription("callr")$GithubSHA1)
#> [1] "31b7c1d06d34070274a602b9372c2b302880dfe4"
data <- runif(1e5)
pryr::object_size(data)
#> 800 kB
f <- function(data) {
  stop("intentional error")
}
system.time(
  tryCatch(
    r(f, args = list(data = data)),
    error = function(e) print(object_size(e$parent$trace$calls))
  )
)
#> 2.51 MB
#>    user  system elapsed 
#>  26.431   0.073  26.451

Created on 2021-03-14 by the reprex package (v1.0.0)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       Ubuntu 18.04.5 LTS          
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language                             
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       America/New_York            
#>  date     2021-03-14                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date       lib source                         
#>  assertthat    0.2.1      2019-03-21 [1] CRAN (R 4.0.2)                 
#>  backports     1.2.1      2020-12-09 [1] CRAN (R 4.0.2)                 
#>  callr       * 3.5.1.9000 2021-03-14 [1] Github (r-lib/callr@31b7c1d)   
#>  cli           2.3.1      2021-02-23 [1] CRAN (R 4.0.2)                 
#>  codetools     0.2-18     2020-11-04 [1] CRAN (R 4.0.2)                 
#>  crayon        1.4.1      2021-02-08 [1] CRAN (R 4.0.2)                 
#>  digest        0.6.27     2020-10-24 [1] CRAN (R 4.0.2)                 
#>  ellipsis      0.3.1      2020-05-15 [1] CRAN (R 4.0.2)                 
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 4.0.2)                 
#>  fansi         0.4.2      2021-01-15 [1] CRAN (R 4.0.2)                 
#>  fs            1.5.0      2020-07-31 [1] CRAN (R 4.0.2)                 
#>  glue          1.4.2      2020-08-27 [1] CRAN (R 4.0.2)                 
#>  highr         0.8        2019-03-20 [1] CRAN (R 4.0.2)                 
#>  htmltools     0.5.1.1    2021-01-22 [1] CRAN (R 4.0.2)                 
#>  knitr         1.31       2021-01-27 [1] CRAN (R 4.0.2)                 
#>  lifecycle     1.0.0      2021-02-15 [1] CRAN (R 4.0.2)                 
#>  magrittr      2.0.1      2020-11-17 [1] CRAN (R 4.0.2)                 
#>  pillar        1.5.1      2021-03-05 [1] CRAN (R 4.0.2)                 
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.0.2)                 
#>  processx      3.4.5.9001 2021-03-14 [1] Github (r-lib/processx@8b6614f)
#>  pryr        * 0.1.4      2018-02-18 [1] CRAN (R 4.0.2)                 
#>  ps            1.6.0      2021-02-28 [1] CRAN (R 4.0.2)                 
#>  purrr         0.3.4      2020-04-17 [1] CRAN (R 4.0.2)                 
#>  R6            2.5.0      2020-10-28 [1] CRAN (R 4.0.2)                 
#>  Rcpp          1.0.6      2021-01-15 [1] CRAN (R 4.0.2)                 
#>  reprex        1.0.0      2021-01-27 [1] CRAN (R 4.0.2)                 
#>  rlang         0.4.10     2020-12-30 [1] CRAN (R 4.0.2)                 
#>  rmarkdown     2.7        2021-02-19 [1] CRAN (R 4.0.2)                 
#>  sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 4.0.2)                 
#>  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.2)                 
#>  styler        1.3.2      2020-02-23 [1] CRAN (R 4.0.2)                 
#>  tibble        3.1.0      2021-02-25 [1] CRAN (R 4.0.2)                 
#>  utf8          1.1.4      2018-05-24 [1] CRAN (R 4.0.2)                 
#>  vctrs         0.3.6      2020-12-17 [1] CRAN (R 4.0.2)                 
#>  withr         2.4.1      2021-01-26 [1] CRAN (R 4.0.2)                 
#>  xfun          0.21       2021-02-10 [1] CRAN (R 4.0.2)                 
#>  yaml          2.2.1      2020-02-01 [1] CRAN (R 4.0.2)                 
#> 
#> [1] /home/landau/R/R-4.0.2/library

When I pass small data or no data at all, the traceback is a smaller object and the delay goes away.

library(callr)
suppressPackageStartupMessages(library(pryr))
print(packageDescription("callr")$GithubSHA1)
#> [1] "31b7c1d06d34070274a602b9372c2b302880dfe4"
f <- function(data) {
  data <- runif(1e5)
  stop("intentional error")
}
system.time(
  tryCatch(
    r(f),
    error = function(e) print(object_size(e$parent$trace$calls))
  )
)
#> 107 kB
#>    user  system elapsed 
#>   0.241   0.040   0.276

Created on 2021-03-14 by the reprex package (v1.0.0)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       Ubuntu 18.04.5 LTS          
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language                             
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       America/New_York            
#>  date     2021-03-14                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date       lib source                         
#>  assertthat    0.2.1      2019-03-21 [1] CRAN (R 4.0.2)                 
#>  backports     1.2.1      2020-12-09 [1] CRAN (R 4.0.2)                 
#>  callr       * 3.5.1.9000 2021-03-14 [1] Github (r-lib/callr@31b7c1d)   
#>  cli           2.3.1      2021-02-23 [1] CRAN (R 4.0.2)                 
#>  codetools     0.2-18     2020-11-04 [1] CRAN (R 4.0.2)                 
#>  crayon        1.4.1      2021-02-08 [1] CRAN (R 4.0.2)                 
#>  digest        0.6.27     2020-10-24 [1] CRAN (R 4.0.2)                 
#>  ellipsis      0.3.1      2020-05-15 [1] CRAN (R 4.0.2)                 
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 4.0.2)                 
#>  fansi         0.4.2      2021-01-15 [1] CRAN (R 4.0.2)                 
#>  fs            1.5.0      2020-07-31 [1] CRAN (R 4.0.2)                 
#>  glue          1.4.2      2020-08-27 [1] CRAN (R 4.0.2)                 
#>  highr         0.8        2019-03-20 [1] CRAN (R 4.0.2)                 
#>  htmltools     0.5.1.1    2021-01-22 [1] CRAN (R 4.0.2)                 
#>  knitr         1.31       2021-01-27 [1] CRAN (R 4.0.2)                 
#>  lifecycle     1.0.0      2021-02-15 [1] CRAN (R 4.0.2)                 
#>  magrittr      2.0.1      2020-11-17 [1] CRAN (R 4.0.2)                 
#>  pillar        1.5.1      2021-03-05 [1] CRAN (R 4.0.2)                 
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.0.2)                 
#>  processx      3.4.5.9001 2021-03-14 [1] Github (r-lib/processx@8b6614f)
#>  pryr        * 0.1.4      2018-02-18 [1] CRAN (R 4.0.2)                 
#>  ps            1.6.0      2021-02-28 [1] CRAN (R 4.0.2)                 
#>  purrr         0.3.4      2020-04-17 [1] CRAN (R 4.0.2)                 
#>  R6            2.5.0      2020-10-28 [1] CRAN (R 4.0.2)                 
#>  Rcpp          1.0.6      2021-01-15 [1] CRAN (R 4.0.2)                 
#>  reprex        1.0.0      2021-01-27 [1] CRAN (R 4.0.2)                 
#>  rlang         0.4.10     2020-12-30 [1] CRAN (R 4.0.2)                 
#>  rmarkdown     2.7        2021-02-19 [1] CRAN (R 4.0.2)                 
#>  sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 4.0.2)                 
#>  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.2)                 
#>  styler        1.3.2      2020-02-23 [1] CRAN (R 4.0.2)                 
#>  tibble        3.1.0      2021-02-25 [1] CRAN (R 4.0.2)                 
#>  utf8          1.1.4      2018-05-24 [1] CRAN (R 4.0.2)                 
#>  vctrs         0.3.6      2020-12-17 [1] CRAN (R 4.0.2)                 
#>  withr         2.4.1      2021-01-26 [1] CRAN (R 4.0.2)                 
#>  xfun          0.21       2021-02-10 [1] CRAN (R 4.0.2)                 
#>  yaml          2.2.1      2020-02-01 [1] CRAN (R 4.0.2)                 
#> 
#> [1] /home/landau/R/R-4.0.2/library
wlandau pushed a commit to ropensci/targets that referenced this issue Mar 14, 2021
@gaborcsardi gaborcsardi added the bug an unexpected problem or unintended behavior label Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants