Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upincr.comp.: Switch to red/green change tracking, remove legacy system. #44901
Conversation
rust-highfive
assigned
nikomatsakis
Sep 28, 2017
alexcrichton
reviewed
Sep 28, 2017
| @@ -79,9 +79,7 @@ pub fn provide_local(providers: &mut Providers) { | |||
| providers.is_exported_symbol = |tcx, id| { | |||
| // FIXME(#42293) needs red/green to not break a bunch of incremental | |||
| // tests | |||
| tcx.dep_graph.with_ignore(|| { | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
kennytm
reviewed
Sep 28, 2017
|
|
||
| profq_msg!(tcx, | ||
| ProfileQueriesMsg::QueryBegin( | ||
| span.clone(), |
This comment has been minimized.
This comment has been minimized.
kennytm
Sep 28, 2017
Member
Should be span.data(). Why needs the clone()?
[00:06:30] error[E0308]: mismatched types
[00:06:30] --> /checkout/src/librustc/ty/maps/plumbing.rs:654:25
[00:06:30] |
[00:06:30] 654 | span.clone(),
[00:06:30] | ^^^^^^^^^^^^ expected struct `syntax_pos::SpanData`, found struct `syntax_pos::Span`
[00:06:30] ...
[00:06:30] 710 | DepKind::RegionScopeTree => { force!(region_scope_tree, def_id!()); }
[00:06:30] | ------------------------------------- in this macro invocation
[00:06:30] |
[00:06:30] = note: expected type `syntax_pos::SpanData`
[00:06:30] found type `syntax_pos::Span`
[00:06:30] = help: here are some functions which might fulfill your needs:
[00:06:30] - .data()
...
[00:06:32] error: aborting due to 110 previous errors
[00:06:32]
[00:06:32] error: Could not compile `rustc`.
This comment has been minimized.
This comment has been minimized.
alexcrichton
added
the
S-waiting-on-review
label
Sep 28, 2017
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Let me know if you want to check perf (try build + ping me). |
michaelwoerister
force-pushed the
michaelwoerister:on-demand-eval
branch
from
a1d7f6c
to
b88c694
Sep 29, 2017
This comment has been minimized.
This comment has been minimized.
|
@Mark-Simulacrum Awesome, thank you! |
michaelwoerister
force-pushed the
michaelwoerister:on-demand-eval
branch
from
b88c694
to
762b735
Sep 29, 2017
This comment has been minimized.
This comment has been minimized.
|
@bors try |
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Sep 29, 2017
michaelwoerister
referenced this pull request
Sep 29, 2017
Closed
Tracking Issue for incr. comp. red/green testing #44716
This comment has been minimized.
This comment has been minimized.
|
|
michaelwoerister
referenced this pull request
Sep 29, 2017
Closed
incr.comp.: Update fingerprint-based auto tests for red/green tracking. #44924
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Thanks, @Mark-Simulacrum! The link does not seem to work for me though at the moment (I see no results listed). |
This comment has been minimized.
This comment has been minimized.
|
Should work now. I think perf.rlo was just not updating for some reason... |
This comment has been minimized.
This comment has been minimized.
|
Thanks, @Mark-Simulacrum! Looks promising. |
michaelwoerister
added some commits
Sep 25, 2017
michaelwoerister
force-pushed the
michaelwoerister:on-demand-eval
branch
from
762b735
to
563d30e
Oct 2, 2017
nikomatsakis
reviewed
Oct 3, 2017
| DepNodeColor::Red | ||
| }; | ||
|
|
||
| assert!(data.colors.borrow_mut().insert(key, color).is_none()); |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Oct 3, 2017
Contributor
Nit: Although I am often tempted to write an assert! like this, I tend to think that putting crucial side-effect operations inside of an assert! is bad-style. Too easy to overlook. I think I'd prefer to see something like:
let old_value = data.colors.borrow_mut().insert(key, color);
assert!(old_value.is_none(), "key {:?} executed twice", key);
This comment has been minimized.
This comment has been minimized.
nikomatsakis
approved these changes
Oct 3, 2017
|
r=me with comments and nits addressed |
| f) | ||
| } | ||
|
|
||
| if let Some(dep_node_index) = tcx.dep_graph.try_mark_green(tcx, &dep_node) { |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Oct 3, 2017
Contributor
I'm curious, why not make try_mark_green check the cache, so we can collapse these two ifs into one? They seem sort of like fundamentally the same case (marked green already vs can mark green now)
This comment has been minimized.
This comment has been minimized.
michaelwoerister
Oct 3, 2017
Author
Contributor
Wouldn't that mean that we always load the result from the cache, even if it is never asked for?
| debug_assert!(tcx.dep_graph.is_green(dep_node_index)); | ||
|
|
||
| // We don't do any caching yet, so recompute | ||
| let (result, diagnostics) = tcx.cycle_check(span, Query::$name(key), || { |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Oct 3, 2017
Contributor
Nit: feels like this maybe wants a subroutine, kind of duplicates the code above.
This comment has been minimized.
This comment has been minimized.
| // We should never get into the situation of having to force this from the DepNode. | ||
| // Since we cannot reconstruct the query key, we would always end up having to evaluate | ||
| // the first caller of this query that *is* reconstructible. This might very well be | ||
| // compile_codegen_unit() in which case we'd lose all re-use. |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Oct 3, 2017
Contributor
I find this comment pretty unclear. What is "this", in the first sentence, referring to? What makes CodegenUnit worse or different from other kinds of depnodes?
This comment has been minimized.
This comment has been minimized.
michaelwoerister
Oct 3, 2017
Author
Contributor
Hm, yeah, I seem to have moved this comment out of context without updating it. CodegenUnit is different because there's no way to reconstruct the query-key from the DepNode, so the "parent query" would have to be re-done. That parent query is compile_codegen_unit(), so we would always have to recompile the codegen unit just to find out that it would not have been necessary.
I'll update the comment and try to make it clearer.
| match dep_node.kind { | ||
| // These are inputs that are expected to be pre-allocated and that | ||
| // should therefore always be red or green already | ||
| DepKind::AllLocalTraitImpls | |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Oct 3, 2017
Contributor
This match feels mildly unfortunate -- i.e., it feels like we ought to be able to derive this information from other macros and not require it to be "re-entered" here. But oh well, I haven't thought about how to actually do that. Might be nice to file a FIXME issue about it though.
This comment has been minimized.
This comment has been minimized.
michaelwoerister
Oct 3, 2017
Author
Contributor
Yeah, it's definitely not pretty. But I didn't want spend too much time on making this macro generated before we have a proof of concept implementation of red/green. I'll add a FIXME.
| @@ -644,15 +664,26 @@ pub(super) struct CurrentDepGraph { | |||
| edges: IndexVec<DepNodeIndexNew, Vec<DepNodeIndexNew>>, | |||
| node_to_node_index: FxHashMap<DepNode, DepNodeIndexNew>, | |||
|
|
|||
| anon_id_seed: Fingerprint, | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Thanks for the review, @nikomatsakis! |
michaelwoerister
referenced this pull request
Oct 4, 2017
Open
incr.comp.: Implement force_from_dep_node() in a macro. #45015
michaelwoerister
force-pushed the
michaelwoerister:on-demand-eval
branch
from
563d30e
to
0454a41
Oct 4, 2017
This comment has been minimized.
This comment has been minimized.
|
@bors r=nikomatsakis |
This comment has been minimized.
This comment has been minimized.
|
|
michaelwoerister
referenced this pull request
Oct 4, 2017
Merged
incr.comp.: Fix infinite recursion in Debug implementation of DepNode #45018
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Oct 4, 2017
This comment has been minimized.
This comment has been minimized.
|
|
bors
merged commit 0454a41
into
rust-lang:master
Oct 4, 2017
This was referenced Oct 4, 2017
This comment has been minimized.
This comment has been minimized.
|
I think we've recovered on all perf benchmarks except two. Everything else either improved since the original regression or was within 5% that I figured it would come out in the wash. Interestingly I think those two benchmarks are the "from scratch build up incremental first time" benchmark, right? |
This comment has been minimized.
This comment has been minimized.
|
perf.rlo is showing me only flat lines right now I think I'll write up a tracking issue for possible performance improvements. |

michaelwoerister commentedSep 28, 2017
This PR finally switches incremental compilation to red/green tracking and completely removes the legacy dependency graph implementation -- which includes a few quite costly passes that are simply not needed with the new system anymore.
There's still some documentation to be done and there's certainly still lots of optimizing and tuning ahead -- but the foundation for red/green is in place with this PR. This has been in the making for a long time
:)r? @nikomatsakis
cc @alexcrichton, @rust-lang/compiler