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

Using future and memoise together #71

Closed
Rekyt opened this issue Feb 6, 2023 · 2 comments
Closed

Using future and memoise together #71

Rekyt opened this issue Feb 6, 2023 · 2 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@Rekyt
Copy link
Member

Rekyt commented Feb 6, 2023

We officially recommended not to use memoise and future at the same time in the fundiversity manuscript.
However, there maybe ways to get both.

I will collect here possibilities to work with both:

It seems for now that using memoise it's not straightforward to parallelize.
Maybe we should be extra-careful and add a warning when loading the package with memoisation that it shouldn't be used with parallelization.
We should also add this in:

  1. The README file
  2. The parallelization vignette
  3. The memoisation documentation segment
  4. The parallelization documentation segment.
@Rekyt Rekyt added documentation Improvements or additions to documentation enhancement New feature or request labels Feb 6, 2023
@Bisaloo
Copy link
Collaborator

Bisaloo commented Feb 6, 2023

Thanks for starting this discussion, this is helpful!

My intuition for R.cache is that it's not worth it in our case. Our tasks are still relatively fast and I'm not sure we can compensate the overhead of opening & writing to file.
We can properly benchmark it at some point. I guess it will depend on how many times the memoised results are reused though and I don't know if we can have an accurate idea of this or if it varies too much between cases.

@Rekyt
Copy link
Member Author

Rekyt commented Dec 3, 2023

If we implement the suggestion from #80 with use_memoise() we could test if the plan is executed sequentially or in parallel, and if it's executed in parallel with the memoise option on show a message to the user that fundiversity fellback to the unmemoised version of functions.

We can check if the plan is sequential or not using plan() without any arguments like the following:

library("future")

# Sequential plan
plan(sequential)
inherits(plan(), "sequential")
#> [1] TRUE

# Other plans
plan(multicore)
inherits(plan(), "sequential")
#> [1] FALSE

plan(multisession)
inherits(plan(), "sequential")
#> [1] FALSE

Created on 2023-12-03 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants