@HenrikBengtsson
Package future provides fundamental building blocks for evaluating R code in parallel
future()
, value()
, and resolved()
%<-%
(future-assignment operator) on top of future()
& value()
Total time: 1 minute
Package future provides fundamental building blocks for evaluating R code in parallel
future()
, value()
, and resolved()
%<-%
(future-assignment operator) on top of future()
& value()
Total time: 1 minute
Total time: 30 seconds
Total time: 15 seconds
These are internally based on the parallel package.
future()
and value()
future()
, value()
, and resolved()
are easy to understand, powerful constructsThese building blocks lay the foundation for higher-level functions:
future_lapply()
and future_replicate()
future_map()
and future_map_dbl()
foreach() %dofuture% { ... }
Parallel alternatives to traditional, sequential functions:
From the very beginning in 2015, the plan and hope has been that additional R backends would become available in the future (pun intended!)
The future.callr package wraps the callr package that is an alternative to the built-in parallel-based multisession
backend:
The future.batchtools package wraps the batchtools package that can run tasks on high-performance compute (HPC) clusters, e.g.
The mirai R package by Charlie Gao (anno 2022)
mirai is Japanese for “future”
Mirai API | Future API | |
---|---|---|
m <- mirai(expr) |
create a future | f <- future(expr) |
r <- !unresolved(m) |
check if done | r <- resolved(f) |
v <- m[] |
wait & get result | v <- value(f) |
Somewhat lower-level interface than the future package
Minimum overhead through highly optimized implementation
Makes mirai ecosystem available to Futureverse
Existing Futureverse code can use it without modification
If you use one of the 100’s of CRAN packages that parallelize via Futureverse, by setting:
plan(future.mirai::mirai_multisession)
you will parallelize via mirai, with all its benefits.
Importantly, by doing so, you will also:
increase the real-world test coverage of mirai
help increase the stability and quality of mirai
Please give feedback and reach out if you run into issues 🙏
Sequential
processing
Parallelization
with 4 workers
Nested parallelization
with 5 workers each
running 3 parallel tasks
Futureverse is well established and well tested
plan(mirai_multisession)
immediatelymirai is is self-contained implementation