[R] slow R start up
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Nov 7 08:44:16 CET 2005
On Mon, 7 Nov 2005, Stuart Macgregor wrote:
> Hi,
> I want to use R within a unix shell script where I repeatedly open
> and close R (doing some computation within R whilst it is open). i.e.
> something like
>
> #!/bin/sh
> R --vanilla << EOF
> # some R commands
> EOF
> # some unix commands
> R --vanilla << EOF
> # some R commands
> EOF
> # some unix commands
> ...etc
>
> the problem is that since I open and close R many times, the shell
> script takes a long time to run (R takes ~1 second to start up, even on
> a fast machine; I've tried various linux installations and versions of R
> from 1.7 to 2.2). Is there some way of making R start up faster? I've
> tried altering the memory start options but this makes little
> difference.
[I don't think your machine _is_ 'fast'! I am seeing 0.3s for a complete
R session on an Opteron 250. We have worked hard to reduce the start-up
time to those levels over the period you quote: please do not belittle
those efforts. R is fast (several times at least) compared to all other
software I use of similar complexity.]
On my 2-year-old i386 box a complete empty session takes 0.5s. You can
reduce that a lot by using fewer default packages. For example, if you
don't need methods or graphics or datasets,
R_DEFAULT_PACKAGES="utils,stats" reduces that to 0.3s, and
R_DEFAULT_PACKAGES=NULL reduces it to 0.05s. We use the latter when using
R for scripting (e.g. in R CMD INSTALL).
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list