[Rake-devel] A handful of issues

Heath Kehoe hkehoe at budcat.com
Mon Jun 7 18:51:25 EDT 2010


On 6/7/2010 4:16 PM, James M. Lawrence wrote:
>
> Yes, my original fix was to replace EARLY with an analogous LATE
> object in FileTask#timestamp.  Although it worked, I was hesitant to
> make a seemingly fundamental change (in the opposite direction, no
> less).  But it's possible that EARLY has been harmlessly wrong for six
> years.
>
>    
There are only two significant places where FileTask#timestamp is used 
(that I found) where changing EARLY to LATE would make a difference. One 
is FileTask#out_of_date? which is only called from FileTask#needed?; and 
when needed? is called where it really counts, the prerequisites have 
all been invoked, so the file-not-found condition should not hit.

The other place is the base Task#timestamp; which propagates the newest 
timestamp of its prereqs, or Time.now if there are no prereqs. The 
ramifications of that timestamp coming back 'LATE' aren't clear to me. 
Nor is it clear to me why it propagates its prereqs' timestamps as its 
own. We could always modify that method to substitute EARLY for LATE to 
preserve the original behavior, which is what I've done.

> Do you have this running on a large project, and does it appear to
> work correctly?  My change removes the old workaround, so you should
> get latest with "gem install drake" or from github (though you'll have
> to add the "if needed?" clause yourself, for the moment).
>
>    

Yes, it has been running on a large project without issue (since not 
long after I posted the patch to the bug report); and much more 
recently, I have implemented the LATE change to FileTask#timestamp. 
Here's what I've got:

module  Rake
     class  Task
         def  timestamp
           @prerequisites.collect  {  |p|
             t  =  application[p].timestamp
             t  ==  Rake::LATE  ?Rake::EARLY  :t
           }.max  ||  Time.now
         end
     end

     class  FileTask  <  Task
         def  needed?
             t  =  timestamp
             t  ==  Rake::LATE  ||  out_of_date?(t)
         end

         def  timestamp
             begin
                 File.mtime(name)
             rescue  Errno::ENOENT
                 Rake::LATE
             end
         end
     end
end

Note, this also contains a couple of additional optimizations I added to 
FileTask's methods to reduce the number of stat syscalls. (With the 
original code, each call to needed? generated 2n+3 stat calls where n is 
the number of file prereqs. This code generates n+1 stat calls.)

I just grabbed drake-0.8.7.0.2.4 and I'll hammer on it and report back 
in a couple days.

-heath


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________


More information about the Rake-devel mailing list