Skip to content

Commit ae78a95

Browse files
Increase default polling frequencies for checking whether a future is resolved and for finding available workers
1 parent 8b7d7a0 commit ae78a95

20 files changed

+52
-52
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: future
2-
Version: 1.34.0-9325
2+
Version: 1.34.0-9326
33
Title: Unified Parallel and Distributed Processing in R for Everyone
44
Imports:
55
digest,

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
but now it's handled automatically by the future framework.
5757

5858
* Add new FutureBackend API for writing future backends.
59+
60+
* Increase default polling frequencies for checking whether a future
61+
is resolved, and for finding available workers.
5962

6063
* Added argument `maxSizeOfObjects` to `future()`, which controls the
6164
maximum total size of objects send to and from the worker. The

R/backend_api-ClusterFutureBackend-class.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ ClusterFutureBackend <- local({
134134
persistent = persistent,
135135
reg = reg,
136136
earlySignal = earlySignal,
137-
future.wait.timeout = getOption("future.wait.timeout", 30 * 24 * 60 * 60),
138-
future.wait.interval = getOption("future.wait.interval", 0.01),
139-
future.wait.alpha = getOption("future.wait.alpha", 1.01),
137+
future.wait.timeout = getOption("future.wait.timeout", 24 * 60 * 60),
138+
future.wait.interval = getOption("future.wait.interval", 0.001),
139+
future.wait.alpha = getOption("future.wait.alpha", 1.001),
140140
...
141141
)
142142
core[["futureClasses"]] <- c("ClusterFuture", core[["futureClasses"]])
@@ -899,7 +899,7 @@ receiveMessageFromWorker <- local({
899899
}) ## receiveMessageFromWorker()
900900

901901

902-
requestNode <- function(await, workers, timeout = getOption("future.wait.timeout", 30 * 24 * 60 * 60), delta = getOption("future.wait.interval", 0.01), alpha = getOption("future.wait.alpha", 1.01)) {
902+
requestNode <- function(await, workers, timeout, delta, alpha) {
903903
debug <- isTRUE(getOption("future.debug"))
904904

905905
stop_if_not(inherits(workers, "cluster"))

R/backend_api-MulticoreFutureBackend-class.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ usedCores <- function() {
149149
#' extensive waiting, then a timeout error is thrown.
150150
#'
151151
#' @keywords internal
152-
requestCore <- function(await, workers = availableCores(), timeout = getOption("future.wait.timeout", 30 * 24 * 60 * 60), delta = getOption("future.wait.interval", 0.01), alpha = getOption("future.wait.alpha", 1.01)) {
152+
requestCore <- function(await, workers = availableCores(), timeout, delta, alpha) {
153153
stop_if_not(length(workers) == 1L, is.numeric(workers), is.finite(workers), workers >= 1)
154154
stop_if_not(is.function(await))
155155
stop_if_not(is.finite(timeout), timeout >= 0)
@@ -234,9 +234,9 @@ MulticoreFutureBackend <- function(workers = availableCores(constraints = "multi
234234
core <- FutureBackend(
235235
workers = workers,
236236
reg = reg,
237-
future.wait.timeout = getOption("future.wait.timeout", 30 * 24 * 60 * 60),
238-
future.wait.interval = getOption("future.wait.interval", 0.01),
239-
future.wait.alpha = getOption("future.wait.alpha", 1.01),
237+
future.wait.timeout = getOption("future.wait.timeout", 24 * 60 * 60),
238+
future.wait.interval = getOption("future.wait.interval", 0.001),
239+
future.wait.alpha = getOption("future.wait.alpha", 1.001),
240240
...,
241241
maxSizeOfObjects = maxSizeOfObjects
242242
)

R/core_api-future.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
#' \preformatted{
114114
#' x <- rnorm(1000)
115115
#' f <- future({
116-
#' library("stats")
116+
#' library(stats)
117117
#' median(x)
118118
#' })
119119
#' }
@@ -128,7 +128,7 @@
128128
#' \preformatted{
129129
#' x <- rnorm(1000)
130130
#' f <- future({
131-
#' library("stats")
131+
#' library(stats)
132132
#' median(x)
133133
#' }, globals = list(x = x))
134134
#' }

R/core_api-value.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ name_of_function <- function(fcn, add_backticks = FALSE) {
290290
#'
291291
#' @rdname value
292292
#' @export
293-
value.list <- function(x, idxs = NULL, recursive = 0, reduce = NULL, stdout = TRUE, signal = TRUE, interrupt = TRUE, inorder = TRUE, drop = FALSE, force = TRUE, sleep = getOption("future.wait.interval", 0.01), ...) {
293+
value.list <- function(x, idxs = NULL, recursive = 0, reduce = NULL, stdout = TRUE, signal = TRUE, interrupt = TRUE, inorder = TRUE, drop = FALSE, force = TRUE, sleep = getOption("future.wait.interval", 0.001), ...) {
294294
if (is.logical(recursive)) {
295295
if (recursive) recursive <- getOption("future.resolve.recursive", 99)
296296
}

R/protected_api-resolve.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@
4545
#' `resolve(futureOf(x))`.
4646
#'
4747
#' @export
48-
resolve <- function(x, idxs = NULL, recursive = 0, result = FALSE, stdout = FALSE, signal = FALSE, force = FALSE, sleep = getOption("future.wait.interval", 0.01), ...) UseMethod("resolve")
48+
resolve <- function(x, idxs = NULL, recursive = 0, result = FALSE, stdout = FALSE, signal = FALSE, force = FALSE, sleep = getOption("future.wait.interval", 0.001), ...) UseMethod("resolve")
4949

5050
#' @export
5151
resolve.default <- function(x, ...) x
5252

5353
#' @export
54-
resolve.Future <- function(x, idxs = NULL, recursive = 0, result = FALSE, stdout = FALSE, signal = FALSE, force = FALSE, sleep = getOption("future.wait.interval", 0.01), ...) {
54+
resolve.Future <- function(x, idxs = NULL, recursive = 0, result = FALSE, stdout = FALSE, signal = FALSE, force = FALSE, sleep = getOption("future.wait.interval", 0.001), ...) {
5555
future <- x
5656

5757
## Automatically update journal entries for Future object
@@ -175,7 +175,7 @@ subset_list <- function(x, idxs = NULL) {
175175

176176

177177
#' @export
178-
resolve.list <- function(x, idxs = NULL, recursive = 0, result = FALSE, stdout = FALSE, signal = FALSE, force = FALSE, sleep = getOption("future.wait.interval", 0.01), ...) {
178+
resolve.list <- function(x, idxs = NULL, recursive = 0, result = FALSE, stdout = FALSE, signal = FALSE, force = FALSE, sleep = getOption("future.wait.interval", 0.001), ...) {
179179
if (is.logical(recursive)) {
180180
if (recursive) recursive <- getOption("future.resolve.recursive", 99)
181181
}
@@ -322,7 +322,7 @@ subset_env <- function(x, idxs = NULL) {
322322

323323

324324
#' @export
325-
resolve.environment <- function(x, idxs = NULL, recursive = 0, result = FALSE, stdout = FALSE, signal = FALSE, force = FALSE, sleep = getOption("future.wait.interval", 0.01), ...) {
325+
resolve.environment <- function(x, idxs = NULL, recursive = 0, result = FALSE, stdout = FALSE, signal = FALSE, force = FALSE, sleep = getOption("future.wait.interval", 0.001), ...) {
326326
if (is.logical(recursive)) {
327327
if (recursive) recursive <- getOption("future.resolve.recursive", 99)
328328
}
@@ -467,7 +467,7 @@ subset_listenv <- function(x, idxs = NULL) {
467467

468468

469469
#' @export
470-
resolve.listenv <- function(x, idxs = NULL, recursive = 0, result = FALSE, stdout = FALSE, signal = FALSE, force = FALSE, sleep = getOption("future.wait.interval", 0.01), ...) {
470+
resolve.listenv <- function(x, idxs = NULL, recursive = 0, result = FALSE, stdout = FALSE, signal = FALSE, force = FALSE, sleep = getOption("future.wait.interval", 0.001), ...) {
471471
if (is.logical(recursive)) {
472472
if (recursive) recursive <- getOption("future.resolve.recursive", 99)
473473
}

R/utils-options.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@
6565
#'
6666
#' \item{\option{future.onFutureCondition.keepFuture}:}{(logical) If `TRUE`, a `FutureCondition` keeps a copy of the `Future` object that triggered the condition. If `FALSE`, it is dropped. (Default: `TRUE`)}
6767
#'
68-
#' \item{\option{future.wait.timeout}:}{(numeric) Maximum waiting time (in seconds) for a free worker before a timeout error is generated. (Default: `30 * 24 * 60 * 60` (= 30 days))}
68+
#' \item{\option{future.wait.timeout}:}{(numeric) Maximum waiting time (in seconds) for a free worker before a timeout error is generated. (Default: `24 * 60 * 60` (= 24 hours))}
6969
#'
7070
#' \item{\option{future.wait.interval}:}{(numeric) Initial interval (in
7171
#' seconds) between polls. This controls the polling frequency for finding
7272
#' an available worker when all workers are currently busy. It also controls
73-
#' the polling frequency of `resolve()`. (Default: `0.01` = 0.01 seconds)}
73+
#' the polling frequency of `resolve()`. (Default: `0.001` = 1 ms)}
7474
#'
75-
#' \item{\option{future.wait.alpha}:}{(numeric) Positive scale factor used to increase the interval after each poll. (Default: `1.01`)}
75+
#' \item{\option{future.wait.alpha}:}{(numeric) Positive scale factor used to increase the interval after each poll. (Default: `1.001`)}
7676
#' }
7777
#'
7878
#' @section Options for debugging futures:

demo/fibonacci.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
library("future")
2-
library("listenv")
1+
library(future)
2+
library(listenv)
33

44
## IMPORTANT:
55
## 1. The below usage of lazy futures will only work when they are

demo/mandelbrot.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
library("future")
2-
library("graphics")
1+
library(future)
2+
library(graphics)
33

44
plot_what_is_done <- function(counts) {
55
for (kk in seq_along(counts)) {

inst/testme/test-cluster,worker-termination.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#' @tags cluster
33

44
library(future)
5-
library("listenv")
5+
library(listenv)
66
options(future.debug = FALSE)
77

88
## IMPORTANT: Since we're killing parallel workers, some of them will not

inst/testme/test-dotdotdot.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#' @tags sequential cluster multisession multicore
33

44
library(future)
5-
library("listenv")
5+
library(listenv)
66

77
for (cores in 1:availCores) {
88
message(sprintf("Testing with %d cores ...", cores))

inst/testme/test-plan.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ future::plan(oplan)
3939
print(future::plan())
4040

4141

42-
library("future")
42+
library(future)
4343

4444
message("*** plan('unknown strategy')")
4545
res <- try(plan('unknown strategy'), silent = TRUE)

inst/testme/test-resolve.R

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
library(future)
66
library(listenv)
7+
options(future.debug = FALSE)
8+
9+
sleep <- function(n) Sys.sleep(0.01*n)
710

811
strategies <- supportedStrategies()
912

@@ -30,14 +33,14 @@ for (strategy in strategies) {
3033
message(sprintf("- result = %s, recursive = %s ...", result, recursive))
3134

3235
f <- future({
33-
Sys.sleep(0.2)
36+
sleep(2)
3437
list(a = 1, b = 42L)
3538
})
3639
res <- resolve(f, result = result, recursive = recursive)
3740
stopifnot(identical(res, f))
3841

3942
f <- future({
40-
Sys.sleep(0.2)
43+
sleep(2)
4144
list(a = 1, b = 42L)
4245
}, lazy = TRUE)
4346
res <- resolve(f, result = result, recursive = recursive)
@@ -100,7 +103,7 @@ for (strategy in strategies) {
100103

101104
x <- list()
102105
x$a <- future(1)
103-
x$b <- future({Sys.sleep(0.2); 2})
106+
x$b <- future({sleep(2); 2})
104107
x[[4]] <- 4
105108
dim(x) <- c(2, 2)
106109
y <- resolve(x, idxs = 1)
@@ -120,12 +123,12 @@ for (strategy in strategies) {
120123
stopifnot(identical(y, x))
121124

122125
x <- list()
123-
for (kk in 1:3) x[[kk]] <- future({ Sys.sleep(0.1); kk })
126+
for (kk in 1:3) x[[kk]] <- future({ sleep(1); kk })
124127
y <- resolve(x)
125128
stopifnot(identical(y, x))
126129

127130
x <- list()
128-
for (kk in 1:3) x[[kk]] <- future({ Sys.sleep(0.1); kk }, lazy = TRUE)
131+
for (kk in 1:3) x[[kk]] <- future({ sleep(1); kk }, lazy = TRUE)
129132
y <- resolve(x)
130133
stopifnot(identical(y, x))
131134

@@ -246,7 +249,7 @@ for (strategy in strategies) {
246249

247250
x <- listenv()
248251
x$a <- future({ 1 })
249-
x$b %<-% { Sys.sleep(0.2); 2 }
252+
x$b %<-% { sleep(2); 2 }
250253
x$c %<-% { 3 }
251254
x$d <- 4
252255
names <- names(x)

inst/testme/test-value.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ attr_on_primitive_is_error <- local({
2121
}
2222
})
2323

24-
sleep <- function(n) Sys.sleep(0.1*n)
24+
sleep <- function(n) Sys.sleep(0.01*n)
2525

2626
identical_envs <- function(x, y) {
2727
if (length(x) > 1) x <- x[order(names(x))]
@@ -153,7 +153,7 @@ for (strategy in strategies) {
153153
x <- list(
154154
a = future({ sleep(2); 3 }, lazy = lazy),
155155
b = future({ sleep(1); 2 }, lazy = lazy),
156-
c = future({ 1 }, lazy = lazy),
156+
c = future({ 1 }, lazy = lazy),
157157
d = data.frame(a = 1, b = 2),
158158
e = 42
159159
)
@@ -166,7 +166,7 @@ for (strategy in strategies) {
166166
x <- list(
167167
a = future({ sleep(2); 3 }, lazy = lazy),
168168
b = future({ sleep(1); 2 }, lazy = lazy),
169-
c = future({ 1 }, lazy = lazy),
169+
c = future({ 1 }, lazy = lazy),
170170
d = data.frame(a = 1, b = 2),
171171
e = 42
172172
)
@@ -179,7 +179,7 @@ for (strategy in strategies) {
179179
x <- list(
180180
a = future({ sleep(2); 3 }, lazy = lazy),
181181
b = future({ sleep(1); 2 }, lazy = lazy),
182-
c = future({ 1 }, lazy = lazy),
182+
c = future({ 1 }, lazy = lazy),
183183
d = 3,
184184
e = 42
185185
)

man/future.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/requestCore.Rd

Lines changed: 1 addition & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/resolve.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/value.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/zzz-future.options.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)