- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Description
For each query invocation the query system will track which other queries have been invoked by the former. We collect this data in the DepGraph and use it to find which queries need to be re-executed in a subsequent compilation session. However, there are some queries (like collect_and_partition_translation_items for example) that access pretty much everything in the current crate and therefore:
- will introduce a lot of dependency edges in the graph, while at the same time
- are very likely to be re-executed if there is even a small change to the code base.
We can take advantage of this domain knowledge by introducing so-called "eval-always" queries. This is a special kind of query where we opt into super coarse-grained dependency tracking: Instead of recording each individual read-edge, we just record a single read to DepNode::Krate. This has the effect that any change will make this query be re-executed.
Note that it is not entirely clear how much of a performance win this can provide but it's certainly interesting to test out.
There are a few steps to implementing this:
- Add a new kind of task in https://github.com/rust-lang/rust/blob/master/src/librustc/dep_graph/graph.rs that behaves like OpenTask::Ignoreinfn read_indexbut, upon closing, registers a read toDepNode::Krate.
- Make the new kind of task available to the outside as DepGraph::with_eval_always_task().
- Allow for declaring a DepKind/DepNodeas "eval_always", the same way it is possible to mark them asanonorinput.
- Make fn try_get_with()in https://github.com/rust-lang/rust/blob/master/src/librustc/ty/maps/plumbing.rs check of theDepNodebeing "eval_always" and if true, executecompute_resultwithinDepGraph::with_eval_always_task()(very similar to theanoncase)
- Switch the following queries to being "eval_always":
- collect_and_partition_translation_items
- lint_levels
- privacy_access_levels(and remove- with_ignorefrom- librustc_privacy::check_crate)
 
Feel free to come up with a better name for "eval-always". It's really not a good name :)