Bug 16133 - 15% speedup in package loading with a one line change, 57% speedup in "ls"
Summary: 15% speedup in package loading with a one line change, 57% speedup in "ls"
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Low-level (show other bugs)
Version: R 3.1.1
Hardware: All All
: P5 enhancement
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2015-01-05 21:29 UTC by Peter Haverty
Modified: 2015-01-07 08:21 UTC (History)
1 user (show)

See Also:


Attachments
timing vignette (18.94 KB, text/html)
2015-01-05 21:29 UTC, Peter Haverty
Details
R code with change to .requirePackage (1.35 KB, text/x-matlab)
2015-01-05 21:30 UTC, Peter Haverty
Details
C code for change to "ls" (1.63 KB, text/x-csrc)
2015-01-05 21:31 UTC, Peter Haverty
Details
diffs for the described changes, vs. R 3.1.1 (6.00 KB, application/x-gzip)
2015-01-06 04:46 UTC, Peter Haverty
Details
diffs to https://svn.r-project.org/R/trunk revision 67339 (739 bytes, application/x-gzip)
2015-01-06 17:15 UTC, Peter Haverty
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Haverty 2015-01-05 21:29:55 UTC
Created attachment 1705 [details]
timing vignette

This is another item related to speeding up package loading.  After resolving a few bottlenecks, "ls" and its use from methods:::.requirePackage become the bottleneck.  In the attached vignette and code, I provide a one line change to .requirePackage that speeds package loading by 15%. I also include a 57% speedup from a minor change to "ls", which has a minor effect on package loading, but will generally be useful.
Comment 1 Peter Haverty 2015-01-05 21:30:51 UTC
Created attachment 1706 [details]
R code with change to .requirePackage
Comment 2 Peter Haverty 2015-01-05 21:31:34 UTC
Created attachment 1707 [details]
C code for change to "ls"
Comment 3 Peter Haverty 2015-01-06 04:46:51 UTC
Created attachment 1711 [details]
diffs for the described changes, vs. R 3.1.1
Comment 4 Martin Maechler 2015-01-06 08:01:09 UTC
(In reply to Peter Haverty from comment #0)
> Created attachment 1705 [details]
> timing vignette
> 
> This is another item related to speeding up package loading.  After
> resolving a few bottlenecks, "ls" and its use from methods:::.requirePackage
> become the bottleneck.  In the attached vignette and code, I provide a one
> line change to .requirePackage that speeds package loading by 15%. I also
> include a 57% speedup from a minor change to "ls", which has a minor effect
> on package loading, but will generally be useful.

This is very promising.  Thanks a lot!

However: 

I've quickly looked at your diff tarball (attachment 1711 [details]), and see that
the changes (e.g. in envir.c) are "huge" compared to what you say above
- one-line change
- minor change to "ls"

Also, can you please use diffs with respect to R-devel (= R trunk) ?
3.1.1 is not even the last released version
Comment 5 Peter Haverty 2015-01-06 17:15:26 UTC
Created attachment 1713 [details]
diffs to https://svn.r-project.org/R/trunk revision 67339
Comment 6 Martin Maechler 2015-01-06 21:57:04 UTC
(In reply to Peter Haverty from comment #5)
> Created attachment 1713 [details]
> diffs to https://svn.r-project.org/R/trunk revision 67339

Looks much better.  Thanks a lot!

I will commit the changes (very slightly annotated (and defun'ed against  "cut and paste duplication") probably within minutes.