plan(cluster) runs gc() on the worker for each future since 1.67.0 (default gc = TRUE)
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 74/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- r
Línea de trabajo
Comience con ClusterFutureBackend(), launchFuture.ClusterFutureBackend() y receiveMessageFromWorker(), y luego reproduzca el ejemplo ms_per_future() del issue. Determine si el valor predeterminado de recolección de basura del worker debería ser FALSE; si se mantiene, actualice NEWS.md y ?cluster. Terminado significa que el valor predeterminado elegido está probado y el comportamiento previsto está documentado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Since future 1.67.0, plan(cluster) runs gc() on the worker before and after each future. With 2 local workers, value(future(1)) takes about 310 ms with plan(cluster) and about 45 ms with plan(multisession), a factor of about 7. With ggplot2, dplyr, Matrix and lme4 loaded on the workers (44 namespaces per worker), plan(cluster) takes about 555 ms.
Is gc = TRUE the intended default for plan(cluster)? The NEWS.md of 1.67.0 does not mention this change, and it is possible that is not intended. ClusterFutureBackend() has the default gc = TRUE. MultisessionFutureBackend() has gc = FALSE. In 1.58.0, cluster() had the argument gc = FALSE, so plan(cluster) did not run gc(). In 1.67.0 and in the development version (1.82.0-9036), cluster() has no gc argument, so the default of the backend applies.
With gc = TRUE, launchFuture.ClusterFutureBackend() calls gc() on the worker before the future, and receiveMessageFromWorker() calls gc() on the worker again after the result.
Here's an example code
library(future)
ms_per_future <- function(n = 20) {
invisible(value(future(1)))
t0 <- proc.time()[["elapsed"]]
for (i in seq_len(n)) value(future(1))
1000 * (proc.time()[["elapsed"]] - t0) / n
}
plan(cluster, workers = 2)
ms_per_future()
# ms per future: 304 to 315
plan(cluster, workers = 2, gc = FALSE)
ms_per_future()
# ms per future: 45
plan(multisession, workers = 2)
ms_per_future()
# ms per future: 45
plan(multisession, workers = 2, gc = TRUE)
ms_per_future()
# ms per future: 300 to 319
# Workers with ggplot2, dplyr, Matrix and lme4 loaded (44 namespaces per
# worker in the runs below; install these packages first):
plan(sequential)
cl <- parallelly::makeClusterPSOCK(2)
invisible(parallel::clusterCall(cl, function() {
for (p in c("ggplot2", "dplyr", "Matrix", "lme4")) loadNamespace(p)
}))
plan(cluster, workers = cl)
ms_per_future()
# ms per future: 554 to 558
plan(cluster, workers = cl, gc = FALSE)
ms_per_future()
# ms per future: 45
plan(sequential)
parallel::stopCluster(cl)
Code that makes many small futures on a cluster runs slower. For example, In the test suite of the projpred package, the parallel tests took 566 s with the default and 174 s with gc = FALSE.
gc = FALSE as the default of ClusterFutureBackend() would restore the behavior of 1.58.0.
If gc = TRUE is intended, it would be good to mention it in NEWS.md and in ?cluster
Thanks for maintaining future!
- Lenguaje dominante
- R
- Estrellas
- 1k
- Forks
- 93
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 1
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de futureverse/future
-
Change repository description?Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 35/100
futureverse/future#849 ·
-
Entire global environment getting passed along with user-defined (global) functions in shinyAbiertobug
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
futureverse/future#833 ·
-
feature/resources RNG
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
futureverse/future#832 ·
-
RNG
Dificultad 5/5 Más de una semana Aptitud para principiantes 38/100
futureverse/future#831 · 1 comentario ·
-
feature request
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
futureverse/future#822 · 1 reacción ·
Todos los issues de futureverse/future
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
nf-core/provenancereport#75 ·
-
Typo in Exercise 5.22?Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
garner-code/PsyR#80 ·