Skip to content
Prev 44300 / 63424 Next

Change in the RNG implementation?

Hi Duncan, Martin,

Thanks for your answers.

For my real case I was generating millions of random positions
on a genome.

I compared sample.int() performance between R-2.15.1 and R-devel,
and, for me, it performs better in R-2.15.1 (almost 3x faster and
also uses slightly less memory):

With R-2.15.1:

   > set.seed(33)

   > system.time(random_chrom_pos <- sample(199000666L, 95000777L))
      user  system elapsed
     4.964   0.268   5.242

   > gc()
              used  (Mb) gc trigger   (Mb)  max used   (Mb)
   Ncells   137285   7.4     350000   18.7    350000   18.7
   Vcells 47633785 363.5  154735917 1180.6 147135703 1122.6

   > sessionInfo()
   R version 2.15.1 (2012-06-22)
   Platform: x86_64-unknown-linux-gnu (64-bit)

   locale:
    [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
    [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
    [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
    [7] LC_PAPER=C                 LC_NAME=C
    [9] LC_ADDRESS=C               LC_TELEPHONE=C
   [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

   attached base packages:
   [1] stats     graphics  grDevices utils     datasets  methods   base

With R-devel:

   > set.seed(33)

   > system.time(random_chrom_pos <- sample(199000666L, 95000777L))
      user  system elapsed
    14.532   0.296  14.854

   > gc()
              used  (Mb) gc trigger   (Mb)  max used   (Mb)
   Ncells   145525   7.8     350000   18.7    350000   18.7
   Vcells 47644082 363.5  152959996 1167.0 182023372 1388.8

   > sessionInfo()
   R Under development (unstable) (2012-10-02 r60861)
   Platform: x86_64-unknown-linux-gnu (64-bit)

   locale:
    [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
    [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
    [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
    [7] LC_PAPER=C                 LC_NAME=C
    [9] LC_ADDRESS=C               LC_TELEPHONE=C
   [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

   attached base packages:
   [1] stats     graphics  grDevices utils     datasets  methods   base

FWIW my R-2.15.1 and R-devel were configured with
--disable-byte-compiled-packages, otherwise, I use all the
defaults. Also my system is a standard Ubuntu 12.04 installation
with no fancy settings/tweakings/customizations.

Thanks,
H.
On 10/20/2012 12:50 PM, Martin Maechler wrote: