future_lapply(),
future_apply(), etc. fell back to a hardcoded 500 MiB limit.Memory use on parallel workers has gone down significantly in some
cases for functions future_lapply(), future_sapply(),
future_apply(), future_tapply(), future_by(),
future_Filter(), future_eapply(), future_mapply(), and
future_Map(). An outcome of this is that the performance also
improves. These improvements come with future (>= 1.80.0).
Separately from the above, the memory use of future_vapply() has
gone down significantly, which also resulted in improved overall
performance.
If argument future.label of future_lapply() and friends has no
format specifier, such as %d, then -%d is appended, e.g.
future.label = "my-label" gives future labels "my-label-1",
"my-label-2", and so on. Previously, such labels produced a
warning 'one argument not used by format'.
future_lapply() and friends now signal "Caught ... Canceling all
iterations ..." as a message instead of a warning.
future_lapply(), future_sapply(), future_vapply(),
future_tapply(), future_eapply(), future_by(), and
future_Filter() ignored ... %seed% seed. This led to random
numbers depending on the future backend, the number of workers, and
the chunk size. Per-element seeds were still generated, but
silently dropped. Note that future_apply(), future_mapply(),
future_.mapply(), and future_Map() were not affected.
future_vapply() on empty input failed with an error if
FUN.VALUE had length greater than one.
future_vapply() did not always return an object of the same type
as FUN.VALUE like vapply() does.
future_vapply() with FUN.VALUE as a list would recursively
flatten the results into an atomic vector instead of returning a
list.
future_lapply() and friends with %seed%, %packages%,
... would leak those options to the next call, if there were zero
elements to process.
future_lapply() and friends with a future.chunk.size less
than one would launch futures that processed no elements. Now such
chunk sizes result in one element per future.
future_apply() with argument future.globals as a list could
produce a false error on globals exceeding the maximum size
allowed.
future_.mapply() could fail with "formal argument matched by
multiple actual arguments" if dots had names also used by
future_mapply(), e.g. "MoreArgs".
future_kernapply() ignored future.* arguments, and any
additional arguments stats::kernapply() might take.
future_apply(..., future.globals = list(...)) would produce
'Error in if (chunk_size > maxSize) { : missing value where
TRUE/FALSE needed'.Added future_Filter(), which is parallel version of
base::Filter().
Added future_kernapply(), which is parallel version of
stats::kernapply().
Now future.apply lets future take care of the generation of parallel RNG seed. Consolidating random number generation to the core package will allow us to add central support for custom parallel RNG methods beyond the built-in L'Ecuyer-CMRG method.
FUN for future_by() as a character
string is defunct. It should be specified as a function, e.g. FUN = sqrt and FUN = `[[` , which is what base::by()
requires. Use of a string has been deprecated since
future.apply 1.10.0 (2022-11-04).future.seed = TRUE could result in an error
!any(seed_next != seed) is not TRUE in rare cases.Option future.globals.maxSize was never passed down to parallel
workers.
The assertion of argument INDEX of future_tapply() would fail
with another error in R (< 3.6.0), if INDEX was incorrect in the
first place.
future_tapply() now accepts data frames as input, just as
tapply() does in R (>= 4.3.0).
In R (>= 4.3.0), future_tapply(X, INDEX, ...) now accepts INDEX
being a formula when X is a data frames, just as tapply() does
in R (>= 4.3.0). An error is produced if used in R (< 4.3.0).
In R (>= 4.3.0), future_by(X, INDICES, ...) now accepts INDICES
being a formula when X is a data frames, just as by() does in
R (>= 4.3.0). An error is produced if used in R (< 4.3.0).
%globals%, %seed%, and %stdout%
can be used to control the corresponding future.* arguments, e.g.
y <- future_lapply(1:3, FUN = my_fun) %seed% TRUE is the same as
y <- future_lapply(1:3, FUN = my_fun, future.seed = TRUE).lapply(X, ...), future_lapply(X, ...) failed to use
method-specific [[ subsetting, if the class of X implemented
one. future_mapply() and other functions had the same problem.
The reason was that when X is partitioned into chunks, it would
lose the class attribute before subsetting with [[.future_eapply(), future_lapply(), future_sapply(),
and future_vapply() failed if FUN was specified as the name of
a function rather than the function object itself,
e.g. future_lapply(1:3, FUN = "sqrt").FUN for future_by() as a character
string is deprecated, because base::by() does not support it. It
should be specified as a function, e.g. FUN = sqrt and FUN = `[[` .future_mapply() and future_Map() was updated to match the new
behavior of mapply() and Map() in R (>= 4.2.0), which follows
the "max-or-0-if-any" recycling rule.future.lazy from all functions. Regardless
of setting it to TRUE or FALSE, futures would be resolved
momentarily and always before the apply returned.citEntry() in CITATION used argument notes instead of note.Add argument future.envir to all future_nnn() functions, which
is passed as argument envir to future().
Add option future.apply.debug for debugging features specific to
this package. It defaults to option future.debug.
getGlobalsAndPackagesXApply() now avoids calculating the
object size of ... arguments if option future.globals.maxSize
is +Inf.f <- function(...) future_lapply(X, function(x) list(...)); f(a=1) would produce an error on 'unused argument (a = 1)" with
the upcoming release of future 1.22.0.The automatic capturing of conditions can be disabled by specifying
future.conditions = NULL.
Warnings and errors on using the RNG without specifying
future.seed are now tailored to the future.apply package.
future_apply() gained argument simplify, which is added to
R-devel (to become R 4.1.0).future_apply(X, FUN, ...) would pass all future.* arguments
except future.globals, future.packages, and future.labels to
the FUN function instead of processing them locally. This would
often result in the FUN producing an error on "unused argument".
It also affected future.seed not being applied, which means for
some FUN functions that did not produce this error,
non-reproducible results could have been produced.future_.mapply() corresponding to .mapply() in the base
package.future_mapply() would chunk up MoreArgs when future.seed = TRUE.future_nnn() functions set a label on each future that
reflects the name of the future_nnn() function and the index of
the chunk, e.g. "future_lapply-3". The format can be controlled
by argument future.label.future_apply().future_lapply(X) and future_mapply(FUN, X) would drop names
argument of the returned empty list when length(X) == 0.
Package could set .Random.seed to NULL, instead of removing it,
which in turn would produce a warning on "'.Random.seed' is not an
integer vector but of type 'NULL', so ignored" when the next random
number generated.
Now future.conditions defaults to the same as argument
conditions of future::future(). If the latter changes, this
package will follow.
Debug messages are now prepended with a timestamp.
future_by().Attributes add and ignore of argument future.globals were
ignored although support for them was added in future (>=
1.10.0).
Validation of L'Ecuyer-CMRG RNG seeds failed in recent R devel.
future.stdout and future.conditions for
controlling whether standard output and conditions (e.g. messages
and warnings) produced during the evaluation of futures should be
captured and relayed or not. Standard output is guaranteed to be
relayed in the same order as it would when using sequential
processing. Analogously for conditions. However, standard output
is always relayed before conditions. Errors are always relayed.
Relaying of non-error conditions requires future (>= 1.11.0).Elements can be processed in random order by setting attribute
ordering to "random" of argument future.chunk.size or
future.scheduling, e.g. future.chunk.size = structure(TRUE, ordering = "random"). This can help improve load balancing in
cases where there is a correlation between processing time and
ordering of the elements. Note that the order of the returned
values is not affected when randomizing the processing order.
Swapped order of arguments future.lazy and future.seed to be
consistent with ditto arguments of future::future().
For list objects X where X != as.list(X), future_lapply(X) did
not give the same result as lapply(X). Analogously for
future_vapply(X).
future_mapply() could drop class attribute on elements iterated
over, because .subset() was used internally instead of `[`(). For instance, iteration over Date objects were affected.
apply(),
Map(), replicate(), sapply(), and tapply(), which are all
GPL (>= 2).Added future_apply(), future_mapply(), and future_Map().
Added argument future.chunk.size as an alternative to argument
future.scheduling for controlling the average number of elements
processed per future ("chunk"). In R 3.5.0, the parallel
package introduced argument chunk.size.
The maximum total size of globals allowed (option
future.globals.maxSize) per future ("chunk") is now scaled up by
the number of elements processed by the future ("chunk") making the
protection approximately invariant to the amount of chunking
(arguments future.scheduling and future.chunk.size).
future_lapply(X, ...) did not search for globals in X.
future_vapply() did not return the same dimension names as
vapply() when FUN.VALUE had no names but FUN(X[[1]]) had.
future_eapply(), future_tapply(), future_vapply(), and
future_replicate().future_lapply(x, ...) is now much faster and more memory
efficient for large x vectors because it uses internal fold()
function that is more efficient (memory and speed) version of
base::Reduce(f, x), especially when length(x) is large.Added future_sapply().
Added future_lapply() - originally from the future package.
Created package.