[Rd] Speed-up/Cache loadNamespace()

Hugh Parsonage hugh@p@r@on@ge @end|ng |rom gm@||@com
Sun Jul 19 20:11:13 CEST 2020


My advice would be to avoid the network in one of the following ways

1. Store installed packages on your local drive
2. Copy the installed packages to a tempdir on your local drive each time
the script is executed
3. Keep an R session running in perpetuity and source the scripts within
that everlasting session
4. Rewrite your scripts to use base R only.

I suspect this solution list is exhaustive.

On Mon, 20 Jul 2020 at 1:50 am, Mario Annau <mario.annau using gmail.com> wrote:

> Dear all,
>
> in our current setting we have our packages stored on a (rather slow)
> network drive and need to invoke short R scripts (using RScript) in a
> timely manner. Most of the script's runtime is spent with package loading
> using library() (or loadNamespace to be precise).
>
> Is there a way to cache the package namespaces as listed in
> loadedNamespaces() and load them into memory before the script is executed?
>
> My first simplistic attempt was to serialize the environment output
> from loadNamespace() to a file and load it before the script is started.
> However, loading the object automatically also loads all the referenced
> namespaces (from the slow network share) which is undesirable for this use
> case.
>
> Cheers,
> Mario
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

	[[alternative HTML version deleted]]



More information about the R-devel mailing list