Spawns N R worker processes that persist across multiple shard_map() calls.
Workers are supervised and recycled when RSS drift exceeds thresholds.
pool_create(
n = parallel::detectCores() - 1L,
rss_limit = "2GB",
rss_drift_threshold = 0.5,
heartbeat_interval = 5,
min_recycle_interval = 1,
init_expr = NULL,
packages = NULL
)A shard_pool object (invisibly). The pool is also stored in the
package environment for reuse.
Integer. Number of worker processes to spawn.
Numeric or character. Maximum RSS per worker before recycling. Can be bytes (numeric) or human-readable (e.g., "2GB"). Default is "2GB".
Numeric. Fraction of RSS increase from baseline that triggers recycling (default 0.5 = 50% growth).
Numeric. Seconds between health checks (default 5).
Numeric. Minimum time in seconds between recycling the same worker (default 1.0). This prevents thrashing PSOCK worker creation under extremely tight RSS limits.
Expression to evaluate in each worker on startup.
Character vector. Packages to load in workers.
# \donttest{
p <- pool_create(2)
pool_stop(p)
# }
Run the code above in your browser using DataLab