Hi, all.
I began to migrate my R codes from Windows to Linux and surprised me
with an old question. I simplified the problem and made a little test to compare
times at same
computer and the Linux time is worse (not so little) than Windows time:
28 vs 53 seconds.
I make an example (below) to facilitate all to see the difference.
I also build from source (it's my first time) a version of R to compare with
the distributed (compiled) R version. The times are similar to the other Linux
version.
I supposed R on Linux should be faster (32 and 64 bit) than windows version. Is
this difference because 64 bit R version is slower than 32 bits one? I started
the machine in both sittuations and checked free memory.
Tecnichal details:
Machine: Intel Core 2 Duo DDR2 4 Gb RAM
Windows version: XP Professional - 32 bits
R version: 2.9* binaries
Linux version: Ubuntu 8* (Hardy) - 64 bits
R version: 2.9* binaries and 2.9* compiled from source
Thanks to all,
Cezar Freitas
#code
N = 50000
n = 15000
#makes data
dad = as.data.frame(cbind(sample(N,N,replace=FALSE), rpois(N,30)))
names(dad) = c("id","age")
aux = as.data.frame(cbind(sample(N,n,replace=FALSE), round(runif(n),4)))
names(aux) = c("id","score")
#calculates time
set.seed(790) #to be equal to everyone
system.time({
dad$score = 0
subdad = subset(dad, id%in%aux$id)
for(k in 1:(dim(subdad)[1])){
temp = aux$score[aux$id==subdad$id[k]]
if(length(temp)) subdad$score[k] = temp
}
})
#windows time
# user system elapsed
# 27.81 0.00 27.82
#linux usual compilation time
# user system elapsed
# 52.635 0.016 52.748
#linux (my compilation) time
# user system elapsed
# 52.567 0.016 52.588
#==============END OF CODE
____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com
[[alternative HTML version deleted]]
On Fri, Jun 26, 2009 at 12:23:35PM -0700, C?zar Freitas wrote:> > I supposed R on Linux should be faster (32 and 64 bit) than windows version. Is this difference because 64 bit R version is slower than 32 bits one? I started the machine in both sittuations and checked free memory. >I suspect that the compiler is to blame. Download Intel's C and C++ compiler for linux (it is free for personal use), try to compile R with it, and see what results you get (and report them here!). Of course, if you have the time and are willing to tinker :)
Yes, under 64-bit it is sometimes slower and it highly depends on the problem and the compiler you have. Note also that nobody managed to get a 64-bit Windows R binary compiled with gcc so far. Remember, 10 years ago there was the SUN Ultra Sparc III and above architecture, and gcc was known to produce extremely inefficient 64-bit binaries for that platform. Things got somewhat better in the meantime. With the tests I used 32-bit R compiled with gcc was roughly 10% slower on Windows than under Linux - but as I said, it depends on the problem. Trying loops versus matrix operations is a way to specify a two very different problems, for example. Uwe Ligges C?zar Freitas wrote:> Hi, all. > > I began to migrate my R codes from Windows to Linux and surprised me > with an old question. I simplified the problem and made a little test to compare times at same > computer and the Linux time is worse (not so little) than Windows time: > 28 vs 53 seconds. > > I make an example (below) to facilitate all to see the difference. > I also build from source (it's my first time) a version of R to compare with the distributed (compiled) R version. The times are similar to the other Linux version. > > I supposed R on Linux should be faster (32 and 64 bit) than windows version. Is this difference because 64 bit R version is slower than 32 bits one? I started the machine in both sittuations and checked free memory. > > Tecnichal details: > Machine: Intel Core 2 Duo DDR2 4 Gb RAM > Windows version: XP Professional - 32 bits > R version: 2.9* binaries > Linux version: Ubuntu 8* (Hardy) - 64 bits > R version: 2.9* binaries and 2.9* compiled from source > > Thanks to all, > Cezar Freitas > > #code > N = 50000 > n = 15000 > > #makes data > dad = as.data.frame(cbind(sample(N,N,replace=FALSE), rpois(N,30))) > names(dad) = c("id","age") > > aux = as.data.frame(cbind(sample(N,n,replace=FALSE), round(runif(n),4))) > names(aux) = c("id","score") > > #calculates time > set.seed(790) #to be equal to everyone > system.time({ > dad$score = 0 > subdad = subset(dad, id%in%aux$id) > for(k in 1:(dim(subdad)[1])){ > temp = aux$score[aux$id==subdad$id[k]] > if(length(temp)) subdad$score[k] = temp > } > }) > > #windows time > # user system elapsed > # 27.81 0.00 27.82 > > #linux usual compilation time > # user system elapsed > # 52.635 0.016 52.748 > > #linux (my compilation) time > # user system elapsed > # 52.567 0.016 52.588 > #==============END OF CODE > > > > > ____________________________________________________________________________________ > Veja quais s?o os assuntos do momento no Yahoo! +Buscados > http://br.maisbuscados.yahoo.com > [[alternative HTML version deleted]] > > > > ------------------------------------------------------------------------ > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Hi, Ilias. I think that is not ok to compare performance in different plataforms
of different machines. To compare times, is necessary you execute the code at
the two plataforms (Linux and Windows) in the same machine.
But the problem here is other. The advanced users explained it well.
So I ask them:
Is it possible build the R (under Linux) and force the compilation make it in 32
bits (at a 64 bits machine)?
Thanks to all,
Cezar Freitas
--- Em seg, 29/6/09, I. Soumpasis <nono.231@gmail.com> escreveu:
De: I. Soumpasis <nono.231@gmail.com>
Assunto: Re: [R] (performance) time in Windows vs Linux
Para: "Cézar Freitas" <cafanselmo12@yahoo.com.br>
Data: Segunda-feira, 29 de Junho de 2009, 5:53
Hi Cezar,
I tried your code in a core duo laptop (@2.5Gz) with ubuntu x86_64 with 4GB of
RAM. Both R and libraries are compiled from source. These are the results.
user system elapsed
23.861 0.812 25.065
It seems better than the windows. Is there a posibility that on linux you have a
big workspace, or something is consuming your memory and thus R is forced to use
swap memory? Just a speculation.
Ilias
PS. BTW It uses only one core.
2009/6/26 Cézar Freitas <cafanselmo12@yahoo.com.br>
#windows time
# user system elapsed
# 27.81 0.00 27.82
#linux usual compilation time
# user system elapsed
# 52.635 0.016 52.748
#linux (my compilation) time
# user system elapsed
# 52.567 0.016 52.588
#==============END OF CODE
____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com
[[alternative HTML version deleted]]
--- Em seg, 29/6/09, I. Soumpasis <nono.231@gmail.com> escreveu:
De: I. Soumpasis <nono.231@gmail.com>
Assunto: Re: [R] (performance) time in Windows vs Linux
Para: "Cézar Freitas" <cafanselmo12@yahoo.com.br>
Data: Segunda-feira, 29 de Junho de 2009, 5:53
Hi Cezar,
I tried your code in a core duo laptop (@2.5Gz) with ubuntu x86_64 with 4GB of
RAM. Both R and libraries are compiled from source. These are the results.
user system elapsed
23.861 0.812 25.065
It seems better than the windows. Is there a posibility that on linux you have a
big workspace, or something is consuming your memory and thus R is forced to use
swap memory? Just a speculation.
Ilias
PS. BTW It uses only one core.
2009/6/26 Cézar Freitas <cafanselmo12@yahoo.com.br>
#windows time
# user system elapsed
# 27.81 0.00 27.82
#linux usual compilation time
# user system elapsed
# 52.635 0.016 52.748
#linux (my compilation) time
# user system elapsed
# 52.567 0.016 52.588
#==============END OF CODE
____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com
[[alternative HTML version deleted]]
2009/6/29 Cézar Freitas <cafanselmo12@yahoo.com.br>> Hi, Ilias. I think that is not ok to compare performance in different > plataforms of different machines. To compare times, is necessary you execute > the code at the two plataforms (Linux and Windows) in the same machine. > But the problem here is other. The advanced users explained it well.This is true. So I tried the same computer with windows XP and ubuntu 8.10 64bit dual core @3Gz and 4MB RAM Windows 32bit results: user system elapsed 21.66 0.02 21.69 Linux 64bit Results user system elapsed 27.242 0.004 27.275 This difference is small and it is truly explained by what the advanced users have said. Regards, Ilias [[alternative HTML version deleted]]