[R] Computational speed question
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Apr 10 16:48:11 CEST 2007
On Tue, 10 Apr 2007, David Vonka wrote:
> I'm doing bootstrap in R 2.4.1 in order to compute standard errors of an
> estimator. I'm running the same program on 4 computers. The core of the
> program is a nlm minimization of a function, which is (I believe) nicely
> coded using (t)apply and all the vectorized stuff.
> I'm slightly puzzled by the differences in the speed of computation. The
> program works twice as fast on a two years old Celeron (256 MB, running
> Ubuntu Dapper Linux) than on a P4 (1GB, Windows 2000 + Novell) and the
> speed of that Celeron is comparable with an other P4 (1GB, Ubuntu Feisty
> Linux). In general (outside R, text editing, whatever), the Celeron is
> much slower than any of the two P4.
> Is there any reason for this ? Is R better optimized for Linux ? Some
> options I might have used when installing R on one of the Linuxes and
> not on the other one ?
R is not better optimized for Linux (and nor is the compiler used) but
Linux is much better optimized for operations using very frequent memory
access than is Windows. Also you haven't told us the details of your
chips. (Not that I really wanted to know, but the size of caches can be
much more important than the clock speed, and P4's are the architecture
most likely to depend on fast caches in my experience.)
BTW, R on Windows is comparable with --enable-R-shlib under Linux, and the
latter has a ca 15% penalty on a i686: the Linux binary distributions are
I believe built that way, but it is not the default. Running R under
Windows and FC5 (with --enable-R-shlib) on the same hardware I see rather
little difference in speed except for some operations like bootstrapping.
There used to be a large overhead (I saw 7x or more) on Windows for
bootstrap-like calculations, but we along ago we added a memory manager
for R (from the same stable as the Linux one) on top of the Windows one.
This usually works well, but not always.
It is always worth trying a later R. That additional malloc layer has
been changed in R 2.5.0 beta and seems to help.
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