-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Refactor BuildContext #8068
Refactor BuildContext #8068
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
I don't know if we should actually merge this. I made this a while ago, but I no longer need it. But Alex said I should post it anyways, so here it is. Some parts I think are a little cleaner. But this is a large PR, touching lots of stuff. It is separated in 2 commits. |
FWIW (as someone who did a bunch of refactoring in this area before), it looks pretty nice to me. |
@ehuss can you remind me the benchmark you're using? I'm curious to test out a few things and see what the perf looks like |
Any project with a lot of crates should work. Cargo itself is a smallish example, servo or something else big works too. The playground's base project is also good as it gets 100 popular crates or about 300 deps total (generated by this script). I also have something similar in cargo-prefetch called make-top which will list the top 1000 crates (pass it a path to a crates.io-index clone). It's a little finicky because of I also use an artificial workspace (though it isn't great because it doesn't have dependencies): #!/bin/sh
set -e
for (( i=0; i<$1; ++i))
do
cargo new --lib dep${i}
done
cat << EOF > Cargo.toml
[workspace]
members = ["dep*"]
EOF Run |
Ok thanks! So here's some things I've tried:
Overall I feel like we can take this a step further (afterwards if you'd prefer) to make |
Those changes sound fine. The Arc is a little unfortunate, but if it doesn't have much performance impact, seems good! I couldn't tell, but it looks like you didn't commit your final experiment removing the Unit lifetime. Here is my old branch where I wrapped Unit in Rc: ehuss@c053288. Doing some more testing, I guess in absolute terms the performance hit isn't too bad. For me, on the playground project, a fresh build goes from 250ms to 270ms. I guess most people won't notice 20ms, although this is a fast-ish machine. If you want, you can push changes to this branch/PR. |
ah ok this explains a bit to me. The I didn't go through the actual removal of the lifetime since it seemed like it would be hard, but I'll go ahead and do so now :) |
Ok I've pushed up the commits I had, in addition to the removal of a lifetime from |
I suppose in terms of next steps, @ehuss want to review what I've done and then we can land this and continue to make progress in-tree? |
☔ The latest upstream changes (presumably #8087) made this pull request unmergeable. Please resolve the merge conflicts. |
OK, looks good! I did some testing and didn't see any performance differences. 🤞 @bors r+ |
📌 Commit 57ad41e1a83da3aafe42895cc29a69414f863539 has been approved by |
🔒 Merge conflict This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again. How do I rebase?Assuming
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial. Please avoid the "Resolve conflicts" button on GitHub. It uses Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Error message
|
☔ The latest upstream changes (presumably #8135) made this pull request unmergeable. Please resolve the merge conflicts. |
This is intended to make it easier to deal with Unit lifetimes.
@bors r=alexcrichton,ehuss |
📌 Commit df5cb70 has been approved by |
☀️ Test successful - checks-azure |
Update cargo, rls ## cargo 17 commits in ebda5065ee8a1e46801380abcbac21a25bc7e755..8751eb3010d4cdb5329b5a6bd2b6d765c95b0dca 2020-04-16 14:28:43 +0000 to 2020-04-21 18:04:35 +0000 - Uplift windows gnu DLL import libraries. (rust-lang/cargo#8141) - Add windows-gnu CI and fix tests (rust-lang/cargo#8139) - Several updates to token/index handling. (rust-lang/cargo#7973) - Add `resolver` opt-in for new feature resolver. (rust-lang/cargo#8129) - Improve error message when running `cargo install .` (rust-lang/cargo#8137) - fix mem replace unused (rust-lang/cargo#8138) - Change `-Cembed-bitcode=no` use to `-Cbitcode-in-rlib=no`. (rust-lang/cargo#8134) - Refactor BuildContext (rust-lang/cargo#8068) - Rename allows_underscores to allows_dashes. (rust-lang/cargo#8135) - Fixed a needless borrow. (rust-lang/cargo#8130) - Add link to changelog in the Cargo book. (rust-lang/cargo#8126) - Fix target for doc test cross compilation (rust-lang/cargo#8094) - Add note about .cargo/config support. (rust-lang/cargo#8125) - Fix pdb uplift when executable has dashes. (rust-lang/cargo#8123) - Hint upgrading for future edition keys (rust-lang/cargo#8122) - Use some fs shorthand functions. (rust-lang/cargo#8124) - Update documentation to mention "config.toml" instead of "config" (rust-lang/cargo#8121) ## rls 1 commits in 2659cbf14bfb0929a16d7ce9b6858d0bb286ede7..7de2a1f299f8744ffe109139f9f1fdf28bfec909 2020-04-14 22:07:24 +0200 to 2020-04-19 22:41:55 +0000 - Update cargo (rust-lang/rls#1663)
This restructures the "front end" of the compile process so that the
UnitGraph
can be accessed by API users. Essentially, theBuildContext
contains the result of generating theUnitGraph
, and other bits of information collected along the way. This logically separates the build process into two phases: (1) generate theUnitGraph
andBuildContext
and (2) pass theBuildContext
toContext
which performs the actual compilation.The main challenge here is dealing with the references and lifetimes. The old code kept a bunch of things on the stack with various layers of references. Beside reorganizing things, the big change is to wrap
Package
andTarget
inRc
. This still requires theUnitInterner
to be passed in and kept alive. It is possible to avoid that by placing allUnit
s inRc
, but that had a roughly 5% performance hit (on fresh builds) because Units are very optimized to be used as hashable keys, andRc
loses those optimizations.