Sets or reads the number of cores that regsen_bounds(),
regsen_breakdown(), regsen_multi() and regsen_boot() use by
default. Each of those also takes an ncores argument for a single
call; this sets the session-wide default those arguments fall back to,
held in options(regsensitivity.ncores).
Arguments
- n
One of:
NULL(default): read the current setting without changing it.a positive integer: use that many cores.
"auto": useparallel::detectCores() - 2, and at least 1. Two are left free so the session, and whatever else the machine is doing, stay responsive.
Whatever is set, at most 2 are used while
R CMD check --as-cranis running, which forbids more.
Details
Parallel runs return exactly what serial runs return. The identified set and the breakdown frontiers draw no random numbers, and the bootstrap seeds each replicate from a vector drawn once up front, so nothing depends on how the work was divided.
On macOS and Linux the work is forked with parallel::mclapply(), so the
data and model need no copying. Windows has no fork; it gets a PSOCK
cluster, which is slower to start and pays to ship the data once, so
there the gain is only worth having for long jobs (a bootstrap, or a
finite-rybar sweep with many grid points).
What is parallel: the grid points of a regsen_bounds() sweep (only the
finite-rybar regime costs anything; the closed forms are cheap either
way), the values of a regsen_breakdown() frontier, the treatments of
regsen_multi(), and the replicates and jackknife of regsen_boot().
Work inside a replicate or a treatment is run serially, so cores are
never oversubscribed by nesting.
