golem icon indicating copy to clipboard operation
golem copied to clipboard

check run_dev() performance

Open VincentGuyader opened this issue 1 year ago • 1 comments

in dev branch, the code :

  if (install_required_packages) {
    install_dev_deps("attachment", force_install = install_required_packages)
    to_install <- attachment::att_from_rscript(path = try_dev)
    install_dev_deps(dev_deps = to_install, force_install = install_required_packages)
  } 

is launched everytime someone launch run_dev().

how long does it take ? maybe try without by setting install_required_packages=FALSE by default, and suggest install_required_packages = TRUE if an error occur

VincentGuyader avatar Aug 10 '23 13:08 VincentGuyader

yes! I thought about filing another feature request with the exact same idea.

you want to be able to call golem::run_dev() repeatadly without setting any arguments (i.e. install_required_packages=FALSE all the time) because many people in a production setting might be reluctant to update

so I would vote for install_required_packages=FALSE

ilyaZar avatar Aug 10 '23 13:08 ilyaZar

As far as I can tell, the package installation will happen just once (if the package is not installed).

After that, the action is very quick (if there is no package to install), given that install_dev_deps() only perform the install if !rlang::is_installed(pak).

for (
    pak in dev_deps
  ) {
    if (!rlang::is_installed(pak)) {
      f(pak, ...)
    }
  }

I'm closing, as I'm not sure it's worth the added complexity of erroring + asking the user to manually install.

f <- \(install_required_packages = TRUE){
    if (install_required_packages) {
      golem:::install_dev_deps("attachment", force_install = install_required_packages)
      to_install <- attachment::att_from_rscript(path = "/private/tmp/deleteme/dev/run_dev.R")
      print(to_install)
      golem:::install_dev_deps(dev_deps = to_install, force_install = install_required_packages)
    }
}
bench::mark({
    f()
})

[1] "httpuv" "sass"   "golem" 
# A tibble: 1 × 13
  expression      min median `itr/sec` mem_alloc `gc/sec` n_itr  n_gc total_time
  <bch:expr> <bch:tm> <bch:>     <dbl> <bch:byt>    <dbl> <int> <dbl>   <bch:tm>
1 { f() }      2.22ms 2.77ms      314.    47.7KB     6.25   151     3      480ms
# ℹ 4 more variables: result <list>, memory <list>, time <list>, gc <list>

ColinFay avatar Jun 21 '24 10:06 ColinFay