[Rd] Speeding up library loading
Ali -
saveez at hotmail.com
Mon Apr 25 20:16:06 CEST 2005
>
> UweL> Ali - wrote:
> >> (1) When R tries to load a library, does it load 'everything' in
>the
> >> library at once?
>
> UweL> No, see ?lazyLoad
>
>are you sure Ali is talking about *package*s.
>He did use the word "library" though, and most of us (including
>Uwe!) know the difference...
>
> >> (2) Is there any options to 'load as you go'?
>
> UweL> Well, this is the way R does it....
>
>for packages yes, because of lazyloading, as Uwe mentioned above.
>
>For libraries, (you know: the things you get from compiling and
>linking C code ..), it may be a bit different.
>
>What do you really mean, packages or libraries,
>Ali?
Well, the terminology used here is a bit confusing. ?library shows something
like 'library(package)' and that's why I used the term 'library' for loading
packages. The package does load some dll's but what I meant by library was
actually package.
The package I am working on currently has one big R file (~ 4 Mb) and this
causes at least 2 troubles:
(1) Things are slow:
(a) Installation with (LazyLoad = Yes) is slow. Then when the library is
loaded into R, the loading is slow too. So LazyLoad is of not big help.
(b) Installation with (SaveImage = Yes) is -extremely- slow. To give you
some idea, compiling the associated C++ code takes around 10 mins while
saving the R images takes more than 40 mins (the package is a wrapper for
some C++ libraries. All the R functions do is to call .Call). this doesn't
improve the loading speed as well.
(c) Installation with (LazyLoad = Yes) AND (SaveImage = Yes) causes this
error:
preparing package <package_name> for lazy loading
make: *** [lazyload] Error 1
*** Installation of <package_name> failed ***
It is likely that this happens because of some memory problems.
(2) After all, when the package is loaded, not surprisingly, loads of memory
is taken. It seems that the whole (huge) file is loaded into R at once and
turning LazyLoad on or off doesn't make a difference when the package is
big.
More information about the R-devel
mailing list