Mac versus Ubuntu

I recently noticed an archived thread discussing the relative performance of R under Linux and Windows. I don’t use Windows, but I do have Ubuntu running on a VirtualBox VM on my Mac. So, I thought it might be interesting to do a little benchmarking. A Google search yielded the following code.

I ran this on both the Ubuntu VM and the Mac. To be clear, this is the same physical machine. Note that I didn’t spend any time getting the instances of R into a similar shape, but I suspect that this would harm Ubuntu more than the Mac. One thing is that I think neither case was RAM-constrained for this particular job.

And the results: Ubuntu is consistently faster, it seems. I’m not sure whether this would carry over to a job that was hard drive-intensive, but I was surprised given the set-up.

Clarification: “Consistently” doesn’t seem to match the data when I look at them again: “hilbert n=500” and “sort n=6” are faster on the Mac. But my general observation is that R is noticeably faster on Ubuntu for many of my tasks. Reading in the same gzipped CSV files today was very noticeably faster on Ubuntu (I go back and forth according to mood, as it so easy with RStudio Server and Dropbox) … I keep figuring it should be faster on the OSX side, but it ain’t. Again, same Batcode, same Batversion of R, same Batmachine.

Mac Pro:                       Ubuntu in VirtualBox.                  
"[1] ""hilbert n=500""      "[1] ""hilbert n=500""
   user  system elapsed      user  system elapsed 
  0.289   0.016   0.304     0.230   0.020   0.383 
   user  system elapsed      user  system elapsed 
  0.298   0.009   0.307     0.280   0.000   0.251 
   user  system elapsed      user  system elapsed 
  0.312   0.009   0.320     0.270   0.000   0.249 
"[1] ""hilbert n=1000""    "[1] ""hilbert n=1000""
   user  system elapsed      user  system elapsed 
  2.287   0.042   2.334     2.040   0.000   1.856 
   user  system elapsed      user  system elapsed 
  2.147   0.021   2.169     2.020   0.000   1.855 
   user  system elapsed      user  system elapsed 
  2.153   0.015   2.168     2.000   0.000   1.847 
"[1] ""sort n=6""              "[1] ""sort n=6""
   user  system elapsed      user  system elapsed 
  0.288   0.000   0.288     0.330   0.000   0.331 
   user  system elapsed      user  system elapsed 
   0.29    0.00    0.29        0.340   0.000   0.317 
   user  system elapsed      user  system elapsed 
  0.289   0.000   0.289     0.330   0.000   0.312 
"[1] ""sort n=7""              "[1] ""sort n=7""
   user  system elapsed      user  system elapsed 
  3.569   0.102   8.397     3.700   0.000   3.596 
   user  system elapsed      user  system elapsed 
  3.508   0.005   3.513     3.620   0.000   3.581 
   user  system elapsed      user  system elapsed 
  3.501   0.001   3.502     3.580   0.000   3.579 
"[1] ""loess n=3""            "[1] ""loess n=3""
   user  system elapsed      user  system elapsed 
  0.067   0.000   0.068     0.060   0.000   0.106 
   user  system elapsed      user  system elapsed 
  0.068   0.000   0.067     0.060   0.000   0.057 
   user  system elapsed      user  system elapsed 
  0.068   0.000   0.067     0.060   0.000   0.055 
   user  system elapsed      user  system elapsed 
  0.068   0.000   0.068     0.050   0.000   0.057 
   user  system elapsed      user  system elapsed 
  0.068   0.000   0.068     0.050   0.000   0.054 
"[1] ""loess n=4""            "[1] ""loess n=4""
   user  system elapsed      user  system elapsed 
  5.812   0.003   5.815     5.050   0.000   4.851 
   user  system elapsed      user  system elapsed 
  5.825   0.004   5.829     4.940   0.000   4.819 
   user  system elapsed      user  system elapsed 
  5.790   0.002   5.793     4.430   0.000   4.531 
   user  system elapsed      user  system elapsed 
  5.821   0.003   5.824     4.640   0.000   4.641 
   user  system elapsed      user  system elapsed 
  5.811   0.001   5.812     4.410   0.000   4.529 

Update

I read a thread discussing alternative BLAS libraries for R here. Suffice to say that the performance difference goes away; in fact the code runs faster under Mac OS X (in some cases noticeably so). Below are updated stats for Mac OS X (same machine as above).

> source("bench.R")
[1] "hilbert n=500"
   user  system elapsed 
  0.261   0.021   0.206 
   user  system elapsed 
  0.220   0.014   0.161 
   user  system elapsed 
  0.219   0.012   0.158 
[1] "hilbert n=1000"
   user  system elapsed 
  1.688   0.103   0.971 
   user  system elapsed 
  1.538   0.110   0.818 
   user  system elapsed 
  1.557   0.110   0.854 
[1] "sort n=6"
   user  system elapsed 
  0.279   0.002   0.281 
   user  system elapsed 
  0.282   0.001   0.284 
   user  system elapsed 
  0.281   0.001   0.283 
[1] "sort n=7"
   user  system elapsed 
  3.479   0.064   3.544 
   user  system elapsed 
  3.442   0.001   3.442 
   user  system elapsed 
  3.433   0.000   3.434 
[1] "loess n=3"
   user  system elapsed 
   0.05    0.00    0.05 
   user  system elapsed 
   0.05    0.00    0.05 
   user  system elapsed 
  0.049   0.000   0.050 
   user  system elapsed 
  0.050   0.000   0.049 
   user  system elapsed 
   0.05    0.00    0.05 
[1] "loess n=4"
   user  system elapsed 
  4.281   0.004   4.286 
   user  system elapsed 
  4.289   0.005   4.294 
   user  system elapsed 
  4.290   0.001   4.291 
   user  system elapsed 
  4.287   0.004   4.292 
   user  system elapsed 
  4.268   0.001   4.269 
Advertisements
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

One Response to Mac versus Ubuntu

  1. Pingback: RStudio Server on a Mac | iangow

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s