Closed alex-lauer closed 1 year ago
Hi @alex-lauer, is it possible you just have a typo? If I take your code and run it in the console line by line I see
> future::plan(multisession, workers = 4)
Error in eval(first, envir = parent.frame(), enclos = baseenv()) :
object 'multisession' not found
This is because we didn't load furrr or future completely, so future::multisession()
isn't available to us.
Is it possible you just missed that error?
Here is a full reprex that works for me, with typos fixed
library(tictoc)
library(purrr)
library(furrr)
#> Loading required package: future
tic()
x <- map_dbl(1:4, function(x){
Sys.sleep(1)
x^2
})
toc()
#> 4.023 sec elapsed
plan(multisession, workers = 4)
tic()
x <- future_map_dbl(1:4, \(x){
Sys.sleep(1)
x^2
})
toc()
#> 1.946 sec elapsed
Created on 2023-02-27 with reprex v2.0.2.9000
Also I encourage you to use the reprex package to create reproducible examples when opening issues! It helps me help you, and often can help you figure out the problem yourself https://reprex.tidyverse.org/articles/learn-reprex.html
Hello,
I tried a (very slightly modified) example code I found in this blogpost, claiming that
furrr
was much faster thanpurrr
. Unfortunately, I couldn't reproduce the results and for mepurrr
is faster:The difference between
purrr
andfurrr
can be up to 10 sec but always favoringpurrr
.Thank you so much for looking into this!
Attaching a sessionInfo for reference:
Matrix products: default
locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 [4] LC_NUMERIC=C LC_TIME=English_United States.utf8
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] tictoc_1.1 formatters_0.3.4.14 furrr_0.3.1 future_1.31.0 purrr_1.0.1
[6] dplyr_1.1.0 here_1.0.1
loaded via a namespace (and not attached): [1] parallelly_1.34.0 rstudioapi_0.14 knitr_1.42 magrittr_2.0.3 tidyselect_1.2.0 R6_2.5.1
[7] rlang_1.0.6 fastmap_1.1.0 fansi_1.0.4 globals_0.16.2 tools_4.2.2 grid_4.2.2
[13] parallel_4.2.2 xfun_0.36 utf8_1.2.2 cli_3.4.1 withr_2.5.0 htmltools_0.5.4
[19] rprojroot_2.0.3 digest_0.6.31 tibble_3.1.8 lifecycle_1.0.3 vctrs_0.5.2 codetools_0.2-18 [25] glue_1.6.2 compiler_4.2.2 pillar_1.8.1 generics_0.1.3 listenv_0.9.0 pkgconfig_2.0.3