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

Remove librustc_ast session globals #74932

Merged
merged 4 commits into from
Aug 8, 2020

Conversation

nnethercote
Copy link
Contributor

By moving the data onto Session.

r? @petrochenkov

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 30, 2020
@nnethercote nnethercote force-pushed the rm-ast-session-globals branch 2 times, most recently from e2cb235 to 6b3064f Compare July 30, 2020 04:18
@nnethercote
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 Jul 30, 2020

⌛ Trying commit 6b3064f7315c9619debcf87aa76cdb1eeb78f237 with merge 3989933cd82bfcf4dd92536dcd76dc61254f4a8d...

@bors
Copy link
Contributor

bors commented Jul 30, 2020

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

@rust-timer
Copy link
Collaborator

Queued 3989933cd82bfcf4dd92536dcd76dc61254f4a8d with parent 6e50a22, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (3989933cd82bfcf4dd92536dcd76dc61254f4a8d): 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

@bjorn3
Copy link
Member

bjorn3 commented Jul 30, 2020

This is a slight (up to 0.4%) slowdown.

src/librustc_metadata/creader.rs Outdated Show resolved Hide resolved
src/librustc_hir/Cargo.toml Outdated Show resolved Hide resolved
@petrochenkov
Copy link
Contributor

I suspect that majority of these check_names don't actually need to mark the attributes as used.
So were not only doing extra work, but now also need to pass Session to locations where it shouldn't otherwise be.
I need to check a couple of things.

@petrochenkov
Copy link
Contributor

I need to check a couple of things.

Blocked on #74952.

@petrochenkov petrochenkov added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 30, 2020
@nnethercote
Copy link
Contributor Author

I suspect that majority of these check_names don't actually need to mark the attributes as used.

I was wondering about that, but I had no sense of which were necessary and which weren't, so I kept them all except for the couple that I couldn't keep. It'd be great if there was a clear rule about when check_name is needed.

@petrochenkov
Copy link
Contributor

petrochenkov commented Aug 1, 2020

I was wondering about that, but I had no sense of which were necessary and which weren't, so I kept them all except for the couple that I couldn't keep. It'd be great if there was a clear rule about when check_name is needed.

I started working on this and will make a PR tomorrow, most likely.
For most attributes there's only a single place where the attribute is lowered into some semantic form, that's also the place where it needs to be marked as used, so the number of mark_useds is roughly equal to the number of different attributes.

UPD: #74952 is the preliminary implementation.

@petrochenkov
Copy link
Contributor

#74952 ended up requiring too much manual work and included some nontrivial cases, so I submitted a simpler #75043 instead.

JohnTitor added a commit to JohnTitor/rust that referenced this pull request Aug 3, 2020
rustc_ast: `(Nested)MetaItem::check_name` -> `has_name`

For consistency with `Attribute::has_name` which doesn't mark the attribute as used either.

Replace all uses of `check_name` with `has_name` outside of rustc, only rustc needs to mark attributes as used.

cc rust-lang#74932
r? @nnethercote
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Aug 4, 2020
rustc_ast: `(Nested)MetaItem::check_name` -> `has_name`

For consistency with `Attribute::has_name` which doesn't mark the attribute as used either.

Replace all uses of `check_name` with `has_name` outside of rustc, only rustc needs to mark attributes as used.

cc rust-lang#74932
r? @nnethercote
@petrochenkov
Copy link
Contributor

#75043 has landed.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Aug 4, 2020
@nnethercote
Copy link
Contributor Author

I have updated. Most of the changes outside of rustc are now no longer necessary, but the changes within rustc are still there. So it's still a big change.

@petrochenkov petrochenkov removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 5, 2020
@petrochenkov petrochenkov added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 7, 2020
@nnethercote
Copy link
Contributor Author

It's a weird rustdoc failure I haven't seen before, only on one of the linux platforms:

error[E0275]: overflow evaluating the requirement `alloc::raw_vec::RawVec<(rustc_ast::ast::UseTree, rustc_ast::ast::NodeId)>: std::marker::Sync`
  |
  = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`rustc_plugin_impl`)
  = note: required because it appears within the type `std::vec::Vec<(rustc_ast::ast::UseTree, rustc_ast::ast::NodeId)>`
  = note: required because it appears within the type `rustc_ast::ast::UseTreeKind`
  ... <lots more lines like that> ...

This is while running rustdoc on the rustc_plugin_impl module. That seems unrelated to my changes, unless we happened to be really close to the recursion limit previously and my patch changed enough things to tip it over the limit?

I'm not sure what to do here, whether it's spurious and likely to disappear if we try again, or if it's likely to recur. If it's the latter, I guess I should add the recusion_limit="256" like the message suggests?

@jyn514, any ideas?

@jyn514
Copy link
Member

jyn514 commented Aug 8, 2020

I wouldn't expect it to be random. I'm not sure how it's related to your change, but it doesn't seem to be an infinite loop so I would try raising the type limit like it suggests.

These arguments are never `None`.
By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This
means they are accessed via the `Session`, rather than via TLS. A few
`Attr` methods and `librustc_ast` functions are now methods of
`Session`.

All of this required passing a `Session` to lots of functions that didn't
already have one. Some of these functions also had arguments removed, because
those arguments could be accessed directly via the `Session` argument.

`contains_feature_attr()` was dead, and is removed.

Some functions were moved from `librustc_ast` elsewhere because they now need
to access `Session`, which isn't available in that crate.
- `entry_point_type()` --> `librustc_builtin_macros`
- `global_allocator_spans()` --> `librustc_metadata`
- `is_proc_macro_attr()` --> `Session`
@nnethercote
Copy link
Contributor Author

I added the 256 recursion limit.

@bors r=petrochenkov

@bors
Copy link
Contributor

bors commented Aug 8, 2020

📌 Commit 96dd044 has been approved by petrochenkov

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 8, 2020
@bors
Copy link
Contributor

bors commented Aug 8, 2020

⌛ Testing commit 96dd044 with merge e61621c...

@bors
Copy link
Contributor

bors commented Aug 8, 2020

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 8, 2020
@bors bors merged commit e61621c into rust-lang:master Aug 8, 2020
@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #74932!

Tested on commit e61621c.
Direct link to PR: #74932

💔 miri on windows: test-fail → build-fail (cc @oli-obk @eddyb @RalfJung).
💔 miri on linux: test-fail → build-fail (cc @oli-obk @eddyb @RalfJung).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Aug 8, 2020
Tested on commit rust-lang/rust@e61621c.
Direct link to PR: <rust-lang/rust#74932>

💔 miri on windows: test-fail → build-fail (cc @oli-obk @eddyb @RalfJung).
💔 miri on linux: test-fail → build-fail (cc @oli-obk @eddyb @RalfJung).
This was referenced Aug 8, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 8, 2020
do not call black_box on Miri

Helps with rust-lang#75274 (but rust-lang#74932 introduced unrelated breakage that will need a separate fix)
Cc @eggyal r? @Mark-Simulacrum
bors added a commit to rust-lang/miri that referenced this pull request Aug 8, 2020
bors added a commit to rust-lang/miri that referenced this pull request Aug 8, 2020
@nnethercote nnethercote deleted the rm-ast-session-globals branch August 9, 2020 22:03
Nemo157 added a commit to Nemo157/rust that referenced this pull request Aug 30, 2020
@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