Skip to content

Commit f5f887c

Browse files
jcheng5shikokuchuo
andauthored
Mention {mirai} in {future} docs (#111)
* Mention mirai in future docs * Apply suggestions from code review Co-authored-by: Charlie Gao <[email protected]> --------- Co-authored-by: Charlie Gao <[email protected]>
1 parent afe4099 commit f5f887c

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

vignettes/promises_04_futures.Rmd

+22
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,28 @@ vignette: >
77
%\VignetteEncoding{UTF-8}
88
---
99

10+
```{css echo=FALSE}
11+
.alert-success a, .alert-success a:visited {
12+
color: inherit;
13+
text-decoration: underline;
14+
}
15+
.alert code {
16+
color: inherit;
17+
background-color: inherit;
18+
}
19+
```
20+
21+
<div class="alert alert-success">
22+
While this article and others on this site focus on the `future` package, there's a much newer package called [`mirai`](https://shikokuchuo.net/mirai/) that you may want to consider instead.
23+
Here are some factors to consider as you choose between the two.
24+
25+
1. The `future` package tries hard to automatically infer what variables and packages you need from the main R package, and makes those available to the child process. `mirai` doesn't try to do this for you; you need to pass in whatever data you need explicitly, and make package-namespaced calls explicitly inside of your inner code.
26+
2. `mirai` is very fast; it's much faster than `future` at starting up and has less per-task overhead. `mirai` creates event-driven promises, whereas promises using `future` time-poll every 0.1 seconds. This makes `mirai` ideal where response times and latency are critical.
27+
3. `future` is designed to be a general API supporting many types of distributed computing backends, and potentially offers more options. `mirai` on the other hand is its own system, whilst it does support both local and distributed execution.
28+
4. `mirai` is inherently queued, meaning it readily accepts more tasks than workers. This means you don’t need an equivalent of `future_promise()`. With `future` you need to manage cases where futures launch other futures ("evaluation topologies") upfront, whereas with `mirai` they will just work.
29+
5. `mirai` supports task cancellation and the ability to interrupt ongoing tasks on the worker.
30+
</div>
31+
1032
The `future` package provides a lightweight way to launch R tasks that don't block the current R session. It was created by Henrik Bengtsson long before the `promises` package existed—the first CRAN release of `future` predates development of `promises` by almost two years.
1133

1234
The `promises` package provides the API for working with the results of async tasks, but it totally abdicates responsibility for actually launching/creating async tasks. The idea is that any number of different packages could be capable of launching async tasks, using whatever techniques they want, but all of them would either return promise objects (or objects that can be converted to promise objects, as is the case for `future`). However, for now, `future` is likely to be the primary or even exclusive way that async tasks are created.

vignettes/promises_06_shiny.Rmd

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ vignette: >
77
%\VignetteEncoding{UTF-8}
88
---
99

10-
<style>
11-
.alert-success a {
12-
color: white;
10+
```{css echo=FALSE}
11+
.alert-success a, .alert-success a:visited {
12+
color: inherit;
1313
text-decoration: underline;
1414
}
15-
</style>
15+
```
16+
1617
<div class="alert alert-success">
1718
As of Shiny 1.8.1, there is a new feature called **Extended Tasks** that has several advantages over the approach in this article. We highly recommend that you read [the Extended Task documentation](https://shiny.posit.co/r/articles/improve/nonblocking/) first.
1819
</div>

0 commit comments

Comments
 (0)