Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incr.comp.: Load cached diagnostics lazily and allow more things in the cache. #46338

Merged
merged 7 commits into from
Dec 1, 2017

Conversation

michaelwoerister
Copy link
Member

@michaelwoerister michaelwoerister commented Nov 28, 2017

This PR implements makes two changes:

  1. Diagnostics are loaded lazily from the incr. comp. cache now. This turned out to be necessary for correctness because diagnostics contain Span values and deserializing those requires that the source file they point to is still around in the current compilation session. Obviously this isn't always the case. Loading them lazily allows for never touching diagnostics that are not valid anymore.
  2. The compiler can now deal with there being no cache entry for a given query invocation. Before, all query results of a cacheable query were always expected to be present in the cache. Now, the compiler can fall back to re-computing the result if there is no cache entry found. This allows for caching things that we cannot force from dep-node (like the symbol_name query). In such a case we'll just have a "best effort" caching strategy.

This PR is based on #46301 (=first 2 commits), so please don't merge until that has landed. The rest of the commits are ready for review though.

r? @nikomatsakis

@kennytm kennytm added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Nov 28, 2017
dep_node: &DepNode)
-> Option<DepNodeIndex> {
pub fn try_mark_green<'a, 'tcx>(&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: use '_' instead of 'a here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a thing now?

@bors
Copy link
Contributor

bors commented Nov 30, 2017

☔ The latest upstream changes (presumably #46299) made this pull request unmergeable. Please resolve the merge conflicts.

@nikomatsakis
Copy link
Contributor

r=me

@michaelwoerister michaelwoerister changed the title [DO NOT MERGE YET] incr.comp.: Load cached diagnostics lazily and allow more things in the cache. incr.comp.: Load cached diagnostics lazily and allow more things in the cache. Dec 1, 2017
@michaelwoerister michaelwoerister removed the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Dec 1, 2017
@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 1, 2017
@michaelwoerister
Copy link
Member Author

OK, travis passed.

@bors r=nikomatsakis p=1

@bors
Copy link
Contributor

bors commented Dec 1, 2017

📌 Commit 966eead has been approved by nikomatsakis

@michaelwoerister michaelwoerister added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 1, 2017
@bors
Copy link
Contributor

bors commented Dec 1, 2017

⌛ Testing commit 966eead with merge 6805b01...

bors added a commit that referenced this pull request Dec 1, 2017
incr.comp.: Load cached diagnostics lazily and allow more things in the cache.

This PR implements makes two changes:
1. Diagnostics are loaded lazily from the incr. comp. cache now. This turned out to be necessary for correctness because diagnostics contain `Span` values and deserializing those requires that the source file they point to is still around in the current compilation session. Obviously this isn't always the case. Loading them lazily allows for never touching diagnostics that are not valid anymore.
2. The compiler can now deal with there being no cache entry for a given query invocation. Before, all query results of a cacheable query were always expected to be present in the cache. Now, the compiler can fall back to re-computing the result if there is no cache entry found. This allows for caching things that we cannot force from dep-node (like the `symbol_name` query). In such a case we'll just have a "best effort" caching strategy.

~~This PR is based on #46301 (=first 2 commits), so please don't merge until that has landed. The rest of the commits are ready for review though.~~

r? @nikomatsakis
@bors
Copy link
Contributor

bors commented Dec 1, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 6805b01 to master...

@bors bors merged commit 966eead into rust-lang:master Dec 1, 2017
@Mark-Simulacrum
Copy link
Member

This appears to have caused a slight regression in performance -- http://perf.rust-lang.org/compare.html?start=e3ed21272d5f50c37c09f2a7f06c40f56b6ac298&end=6805b016efdfcd99e706003fab1336df73f6811b&stat=wall-time -- was that expected?

@michaelwoerister
Copy link
Member Author

Bummer, I would have hoped that the slightly more efficient span hashing implementation would make things faster. But it seems that also encoding and decoding expansion contexts adds some noticeable overhead for some crates. Fortunately it doesn't seem too bad -- except for crates.io again. This one seems to be rather sensitive to span related changes.

bors added a commit that referenced this pull request Dec 14, 2017
incr.comp.: Speed up span hashing by caching expansion context hashes.

This PR fixes the performance regressions from #46338.

r? @nikomatsakis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants