The future package provides a generic API for using futures in R. A future is a simple yet powerful mechanism to evaluate an R expression and retrieve its value at some point in time. Futures can be resolved in many different ways depending on which strategy is used. There are various types of synchronous and asynchronous futures to choose from in the future package.
This is obviously a toy example to illustrate what futures look like and how to work with them. For further examples on how to use futures, see the vignettes of the future package as well as those of future.apply and doFuture.
The future.mirai package implements a future backend wrapper for mirai.
|Backend||Description||Alternative in future package|
||parallel evaluation in a separate R process (on current machine)||
mirai futures, each future is resolved in a fresh background R session which ends as soon as the value of the future has been collected. In contrast,
multisession futures are resolved in background R worker sessions that serve multiple futures over their life spans. The advantage with using a new R process for each future is that it is that the R environment is guaranteed not to be contaminated by previous futures, e.g. memory allocations, finalizers, modified options, and loaded and attached packages. The disadvantage, is an added overhead of launching a new R process.
The future package provides a demo using futures for calculating a set of Mandelbrot planes. The demo does not assume anything about what type of futures are used. The user has full control of how futures are evaluated. For instance, to use
mirai_multisession futures, run the demo as:
R package future.mirai is only available via GitHub and can be installed in R as:
To install the pre-release version that is available in Git branch
develop on GitHub, use:
This will install the package from source.