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

Lazy decoding of DefPathTable from crate metadata (non-incremental case) #75813

Merged
merged 3 commits into from
Aug 23, 2020

Conversation

petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented Aug 22, 2020

The is the half of #74967 that doesn't touch incremental-related structures.
We are still decoding def path hashes eagerly if we are in incremental mode.

The incremental part of #74967 feels hacky, but I'm not qualified enough to suggest improvements. I'll reassign it so someone else once this PR lands.
@Aaron1011, I wasn't asking you to do this split because I wasn't sure that it's feasible (or simple to do).

r? @Aaron1011

UPD: Self-contained description:

Previously, we decoded the entire DefPathTable up front when loading crate
metadata. This is wasteful if we only ever access a few definitions from
the crate.

This PR modifies the crate metadata to decode entries from the
DefPathTable lazily, resulting in significant improvements on several
benchmarks. Instead of encoding a DefPathTable, we encode two Tables
containing the content of the DefPathTable. This allows us to decode
entires for a single DefIndex at a time.

If incremental compilation is enabled, then we still have to partially decode the contents of DefPathTable up front, but only def path hashes.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 22, 2020
@petrochenkov
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Aug 22, 2020

⌛ Trying commit df57e28 with merge 5bfc961207c712abcd597589d06a63035ab54a69...

@petrochenkov
Copy link
Contributor Author

Dammit, forgot the capacity commit (15643d5) before starting perf.

@petrochenkov
Copy link
Contributor Author

Ok, rust-timer didn't start anyway (probably due to pushes).
@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Aug 22, 2020

⌛ Trying commit 6a5e657 with merge d55cd4439a28e659793f7cdf4f25280fc106d0f0...

@bors
Copy link
Contributor

bors commented Aug 22, 2020

☀️ Try build successful - checks-actions, checks-azure
Build commit: d55cd4439a28e659793f7cdf4f25280fc106d0f0 (d55cd4439a28e659793f7cdf4f25280fc106d0f0)

@rust-timer
Copy link
Collaborator

Queued d55cd4439a28e659793f7cdf4f25280fc106d0f0 with parent 663d2f5, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (d55cd4439a28e659793f7cdf4f25280fc106d0f0): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never

@Aaron1011
Copy link
Member

@petrochenkov: Thanks for splitting this out!

@bors r+

@bors
Copy link
Contributor

bors commented Aug 22, 2020

📌 Commit 6a5e657 has been approved by Aaron1011

@bors bors 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 Aug 22, 2020
@bors
Copy link
Contributor

bors commented Aug 23, 2020

⌛ Testing commit 6a5e657 with merge d5abc8d...

@bors
Copy link
Contributor

bors commented Aug 23, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: Aaron1011
Pushing d5abc8d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 23, 2020
@bors bors merged commit d5abc8d into rust-lang:master Aug 23, 2020
@rust-log-analyzer
Copy link
Collaborator

Your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
##[section]Starting: Request a runner to run this job
Found online and idle self-hosted runner in current repository that matches the required labels: 'self-hosted , ARM64 , linux'

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

@ecstatic-morse
Copy link
Contributor

ecstatic-morse commented Aug 24, 2020

Final perf results show a major win on the smaller benchmarks where we seem to spend a lot of our time serializing and deserializing crate metadata. However, this is also a noticeable improvement on some non-trivial benchmarks like the futures crate. Nice work!

@petrochenkov petrochenkov mentioned this pull request Aug 31, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 1, 2020
…, r=pnkfelix

Implement lazy decoding of DefPathTable during incremental compilation

PR rust-lang#75813 implemented lazy decoding of the `DefPathTable` from crate metadata. However, it requires decoding the entire `DefPathTable` when incremental compilation is active, so that we can map a decoded `DefPathHash` to a `DefId` from an arbitrary crate.

This PR adds support for lazy decoding of dependency `DefPathTable`s when incremental compilation si active.

When we load the incremental cache and dep
graph, we need the ability to map a `DefPathHash` to a `DefId` in the
current compilation session (if the corresponding definition still
exists).

This is accomplished by storing the old `DefId` (that is, the `DefId`
from the previous compilation session) for each `DefPathHash` we need to
remap. Since a `DefPathHash` includes the owning crate, the old crate is
guaranteed to be the right one (if the definition still exists). We then
use the old `DefIndex` as an initial guess, which we validate by
comparing the expected and actual `DefPathHash`es. In most cases,
foreign crates will be completely unchanged, which means that we our
guess will be correct. If our guess is wrong, we fall back to decoding
the entire `DefPathTable` for the foreign crate. This still represents
an improvement over the status quo, since we can skip decoding the
entire `DefPathTable` for other crates (where all of our guesses were
correct).
@cuviper cuviper added this to the 1.47.0 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

8 participants