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.: Introduce `ensure` and `ensure` typeck_tables_of #45228
Conversation
theotherjimmy
added some commits
Oct 11, 2017
rust-highfive
assigned
nikomatsakis
Oct 12, 2017
This comment has been minimized.
This comment has been minimized.
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
theotherjimmy
reviewed
Oct 12, 2017
| if !tcx.dep_graph.is_fully_enabled() { | ||
| let _ = tcx.$name(key); | ||
| return; | ||
| } |
This comment has been minimized.
This comment has been minimized.
theotherjimmy
Oct 12, 2017
Author
Contributor
@nikomatsakis Open question: Should the preceding 4 lines be in try_mark_green?
This comment has been minimized.
This comment has been minimized.
theotherjimmy
Oct 12, 2017
Author
Contributor
For reference, try_mark_green will unwrap a None here if tcx.dep_graph.is_fully_enabled() would return False.
This comment has been minimized.
This comment has been minimized.
michaelwoerister
Oct 12, 2017
Contributor
I'd rather keep the explicit panic in try_mark_green, I think.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Oct 13, 2017
Contributor
I also expected those lines to be in try_mark_green, but I trust @michaelwoerister's intuitions here. =) That said, I think we could consider trying to extract some of the common code between this function and try_get_with. I had thought it might make sense to extract a helper function that returns Some(dep_node_index) if either: the node color is green or can be made green, and None otherwise. This function here could invoke tcx.$name(key) if None is returned, and try_get_with can do whatever it does now.
This comment has been minimized.
This comment has been minimized.
theotherjimmy
Oct 13, 2017
Author
Contributor
I like it! I'll implement that refactor as a follow on PR, unless this round of testing does not go well and I have to fix something.
theotherjimmy
referenced this pull request
Oct 12, 2017
Open
[incremental] skip type-checking #45208
michaelwoerister
reviewed
Oct 12, 2017
| use dep_graph::DepNodeColor; | ||
| match tcx.dep_graph.node_color(&dep_node) { | ||
| Some(DepNodeColor::Green(dep_node_index)) => { | ||
| profq_msg!(tcx, ProfileQueriesMsg::CacheHit); |
This comment has been minimized.
This comment has been minimized.
michaelwoerister
Oct 12, 2017
Contributor
We shouldn't do any profq_msg! calls in this method for now. We'll have to talk to @matthewhammer at some point about how to properly integrate the new tracking system with the query profiler.
This comment has been minimized.
This comment has been minimized.
michaelwoerister
reviewed
Oct 12, 2017
| tcx.dep_graph.read_index(dep_node_index); | ||
| } | ||
| Some(DepNodeColor::Red) => { | ||
| let _ = tcx.$name(key); |
This comment has been minimized.
This comment has been minimized.
michaelwoerister
Oct 12, 2017
Contributor
Could you add a comment here saying something like:
The DepNode being DepNodeColor::Red means that this query has been already executed before. We are still calling the proper again in order to issue the appropriate
dep_graph.read()call. The performance cost this introduces should be negligible because we'll immediately hit the in-memory cache.
This comment has been minimized.
This comment has been minimized.
theotherjimmy
added some commits
Oct 12, 2017
This comment has been minimized.
This comment has been minimized.
|
@michaelwoerister I think I corrected everything you pointed out in your review comments. Thanks for the review! |
This comment has been minimized.
This comment has been minimized.
|
Thanks @theotherjimmy! @bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
kennytm
added
the
S-waiting-on-bors
label
Oct 13, 2017
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Oct 15, 2017
This comment has been minimized.
This comment has been minimized.
|
|
bors
merged commit d0cb4d0
into
rust-lang:master
Oct 15, 2017
theotherjimmy
referenced this pull request
Oct 15, 2017
Merged
Refactor `ensure` and `try_get_with` #45312
This comment has been minimized.
This comment has been minimized.
|
|
theotherjimmy commentedOct 12, 2017
Resolves #45210
In this Pull Request we introduce the
ensurequery/function.ensurehas thesemantics and type of the function
Q1below:Further,
ensureavoids the need to load the result from disk (or execute theprovider, if we are not storing the results of Q to disk).
@nikomatsakis