Changes between Version 8 and Version 9 of DependencyAnalysis

Show
Ignore:
Timestamp:
05/28/08 19:59:04 (5 years ago)
Author:
Saizan
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DependencyAnalysis

    v8 v9  
    100100 
    101101will do the trick. 
     102 
     103---- 
     104== Generalize Dependencies == 
     105 
     106If we want to cache the result of things like finding the rule chain (as above) or deal correctly with searchpath shadowing, we need to track how the algorithm depended on the environment so that we can see if the result is still valid in the current one. This means that they are part of the dependency graph as well. 
     107 
     108This introduces new kinds of nodes, e.g. both the mentioned algorithms need to test if a file exists, which is different from depending on a file's content, so FilePath is no more a proper representation for nodes. 
     109 
     110{{{ data Target = File FilePath | FileExist FilePath | ... }}} 
     111 
     112We can also consider that we don't need .dep files to be stored on the filesystem, but they can be more efficiently stored in a dictionary serialized between runs. 
     113 
     114{{{ ... | DictEntry Name Content | ... }}} 
     115 
     116A discriminated union like this is not very extensible but it's probably the simplest approach, especially in h98. 
     117 
     118=== Determine if a target is up to date === 
     119 
     120Considering only files we can solve this by checking if target T is older than all its dependencies, using timestamps.  
     121 
     122If T depends on {{{d = FileExist "foo.hs" instead}}}, we have a problem since we can't assing a sensibile timestamp to {{{d}}}, what really matters if the value computed for that dependency has changed or not wrt when we built T, so we can test this condition by storing the old value (that we'll call the representation, in this case a Bool) and compare it to the current one. 
     123 
     124If all the cached representations are equal to the ones in the current environment for both the dependencies and the target, then we don't have to build T again, since the old one is still valid.  
     125 
     126This assumes that we consider as valid the representations of the dependecies. So they must have already passed this test or have been recomputed, which leads to traversing the graph top-down, from sources to sinks. 
     127 
     128If some representation is missing than we just consider T not valid and build it. Missing the current representation for dependencies is a bit anomalous since the algorithm should have produced them earlier, but concurrent user interaction could cause this. 
     129 
     130This works nicely also for plain files: storing the whole content and comparing it would be exactly the correct condition to check, but it's too expensive, so we use timestamps as representations for files as before, to keep the comparison cheap. 
     131 
     132We get something that is a little more accurate than the simple "T older than D" check, since just touch-ing T won't work as the timestamp won't coincide. 
     133 
     134It also means that we can't make use of targets for which we don't have a cached representation without rerunning the action to produce them, but this shouldn't be a problem. 
     135 
     136It's important that the core make algorithm doesn't care about the internal structure of Targets or Representations, as long as it can retrieve the old and current representation for a target and compare them for equality. 
     137 
     138 
     139