Consider the following example where all except the first work package take the same amount of time.
library("tidyverse")
library("future")
library("future.apply")
future::plan("multisession", workers=4)
num_workers <- future::nbrOfWorkers()
f <- function(i){
if(i==1){
Sys.sleep(10)
} else {
Sys.sleep(1)
}
data.frame(
i=i,
pid=Sys.getpid(),
timepoint=Sys.time()
)
}
future_lapply(1:(5*num_workers), f) %>%
bind_rows() %>%
mutate(worker_nr=map_dbl(pid, ~which(.x==unique(pid)))) %>%
arrange(timepoint)
The result is that all workers except the one evaluating f(1) finish almost simultaneously, while worker nr. 1 lags behind and it's remaining work is not distributed while all other workers are idle:

Is this an issue or is there a way to specify that unfinished work should be distributed to all available workers? I observed the phenomenon with the future.apply and furrr package, so I think it's directly related to future.
Consider the following example where all except the first work package take the same amount of time.
The result is that all workers except the one evaluating
f(1)finish almost simultaneously, while worker nr. 1 lags behind and it's remaining work is not distributed while all other workers are idle:Is this an issue or is there a way to specify that unfinished work should be distributed to all available workers? I observed the phenomenon with the
future.applyandfurrrpackage, so I think it's directly related tofuture.