(cross posted to Ruby Talk and Rake-devel)
Jim Weirich wrote:
It is more likely that the cause of a slow rake startup is the time it
takes to calculate any filelists used for dependency detection. For
example, the filelist used for the clean target searches your entire
project tree looking for files that can be deleted. An obvious
optimization would be to delay the creation of a filelist until we
really need it.
If slow startups are a problem, I’ll look into some possible fixes.
Several people have indicated to me that the startup is a minor problem.
The following URL is for a experimental gem for rake that using
delayed filelists.
http://onestepback.org/software/rake/download/rake-0.3.2.2.gem
(NOTE: don't move this to a gem server until I get some feedback on
it, thanks)
FileLists (array-like objects that contain file names) are normally
built at the time they are declared. This can be quite expensive. For
example:
SOURCE_FILES = FileList['**/*.rb']
will search your entire project tree and find all the ruby source files
and add them to the SOURCE_FILES file list. If done at the top level of
a rakefile (and most are), this list will be done on every invocation of
rake (even if you say “rake --help”).
In the experimental gem above, the building of the FileList is actually
delayed until the first time the data is required. If the file list is
used in a dependency calculation, you probably won’t see any difference.
If the file list is only used in the body of a task (such as the CLEAN
list, which is a major offender), then this should speed things up a bit.
For those who have noticed slow starts, give this gem a try and let me
know if it helps or if it causes other problems.
Thanks!
Some GEM Instructions:
If you have rake installed as a gem, just download the URL above and do
a local gem installation (e.g. gem -Li rake-0.3.3.2.gem) and you can
start using it immediately. If you wish to uninstall it, then just do a
“gem -U rake” and select the 0.3.3.2 version. The previous gem
version of rake should be reestablished.
If you are not using the gem version of rake, than grab the latest CVS
and install it normally.
···
“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)