[R] switching to Linux, suggestions?

lederer@trium.de lederer at trium.de
Sun Dec 12 22:48:15 CET 2004


Hi,

recently, i installed Gentoo in addition to SuSE on my Laptop.
In order to see whether it was worth the effort, i did a small
benchmark for R under SuSE and Gentoo.
I guess, that the benchmarks under SuSE are also approximately
valid for other binary distributions.

As a consequence, depending on your Unix/Linux experience,
i would recommend Gentoo for optimal performance.
If you are new to Linux and want to avoid the relatively complicated
Gentoo setup, i recommend that you should least compile R from source,
which should be easy also for a Linux newbie.

The benchmark (see below for the script) consisted of
i) Generating random normals and plotting density plots.
ii) Cox model
iii) Inverting random 200x200 matrices.

I used different versions of R, since 2.0.1 is not yet included in the
Gentoo portage tree. Here are my results:

A) SuSE 9.2, R 2.0.1 (from i586 rpm):
                 benchmark cpu.user cpu.system
1        benchmark.density   222.22       6.76
11      benchmark.survival   133.69       0.27
12 benchmark.linearalgebra   365.25       3.64

B) R 1.9.0 compiled under SuSE 9.2, without additional CFLAGS
(i.e. using CFLAGS from the configure script):
                 benchmark cpu.user cpu.system
1        benchmark.density   217.31       6.12
11      benchmark.survival   101.77       0.14
12 benchmark.linearalgebra   165.49       3.34

C) R 1.9.0 compiled under SuSE 9.2, using the same CFLAGS
as in Gentoo (see below for my CFLAGS):
                 benchmark cpu.user cpu.system
1        benchmark.density   199.16       5.96
11      benchmark.survival    94.26       0.15
12 benchmark.linearalgebra   159.17       4.93

D) R 1.9.0-r1 under Gentoo, using the CFLAGS for the whole system,
not just for R.
                 benchmark cpu.user cpu.system
1        benchmark.density   176.08       6.10
11      benchmark.survival    84.20       0.14
12 benchmark.linearalgebra   134.72       6.54

My CFLAGS (for a centrino) are:
CFLAGS="-pipe -O3 -march=pentium4 -mmmx -msse -msse2 -mfpmath=sse,387
-maccumulate-outgoing-args -mno-align-stringops -fomit-frame-pointer
-ffast-math -fsched-spec-load -fprefetch-loop-arrays -ftracer
-fmove-all-movables"

Question to the Gurus: Would it be allowed, to use
-funsafe-math-optimizations?


Here is my benchmark script:

--------------------------------------------------
require(survival)

benchmark.density <- function()
{
    for (i in 1:1000)
    {
        x <- rnorm(100000)
        plot(density(x), type="l", xlim=c(-10,10), main=i)
    }
}

benchmark.survival <- function()
{
    for (i in 1:1000)
    {
        time <- c(rexp(800, 1), rexp(800, 0.8), rexp(800, 0.9),
                  rexp(800, 0.7), rexp(800, 0.5))
        time <- round(time, digits=2)  # introduce ties
        event <- as.integer(time <= 1)
        time[time > 1] <- 1
        group <- c(rep(0, 800), rep(1, 800), rep(2, 800),
                   rep(3, 800), rep(4, 800))
        plot(survfit(Surv(time,event) ~ group), xlim=c(0,1))
        title(main=i)
        dummy <- coxph(Surv(time,event) ~ group)
    }
}


benchmark.linearalgebra <- function()
{
    for (i in 1:1000)
    {
        A <- matrix(rnorm(200*200), nrow=200, ncol=200)
        AI <- solve(A)
        residual <- A %*% AI - diag(1, 200)
        hist(residual, main=i)
    }
}


my.benchmark <- function(func)
{
   funcname <- (as.character(sys.call()[[2]]))
   cat(funcname, "\n")
   times <- system.time(func())
   return(data.frame(benchmark=funcname,
                     cpu.user=times[1],
                     cpu.system=times[2]))
}

result <- my.benchmark(benchmark.density)
result <- rbind(result, my.benchmark(benchmark.survival))
result <- rbind(result, my.benchmark(benchmark.linearalgebra))

sink("benchmark.out")
cat(Sys.info(), "\n")
print(result)
sink()
--------------------------------------------------------------

Christian


> Dear List,
> I have acquired a new desktop and wanted to put a free OS on it.  I am
> trying Fedora Core 1, but not sure what the best Linux OS is for using R
> 2.0.1?
>
> Thank you in advance for your input,
> Tom Volscho
>
> ************************************
> Thomas W. Volscho
> Graduate Student
> Dept. of Sociology U-2068
> University of Connecticut
> Storrs, CT 06269
> Phone: (860) 486-3882
> http://vm.uconn.edu/~twv00001
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list