Remove HashStable impl for [hir::Attribute].#154924
Remove HashStable impl for [hir::Attribute].#154924nnethercote wants to merge 1 commit intorust-lang:mainfrom
HashStable impl for [hir::Attribute].#154924Conversation
|
I'm looking into this because this impl is blocking a larger clean-up of stable hashing that I am working on. @bors try |
This comment has been minimized.
This comment has been minimized.
…, r=<try> Remove `HashStable` impl for `[hir::Attribute]`.
|
Based on the attributes, it looks like they were used for some incremental tests. |
|
@rust-timer queue |
This comment has been minimized.
This comment has been minimized.
|
@rust-timer build a656fa4 |
This comment has been minimized.
This comment has been minimized.
| .filter(|attr| { | ||
| attr.is_doc_comment().is_none() | ||
| // FIXME(jdonszelmann) have a better way to handle ignored attrs | ||
| && !attr.name().is_some_and(|ident| is_ignored_attr(ident)) |
There was a problem hiding this comment.
In fact attr.name() is not implemented for parsed attributes, so this check is always false.
Since other than cfg_trace all the attributes are only used for incremental tests, and the incremental tests still pass, I don't think this check is useful
There was a problem hiding this comment.
(attr.name() will be removed in the near future, as a follow-up of #154808)
|
Finished benchmarking commit (a656fa4): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 1.9%, secondary 2.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResults (primary -0.0%, secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 486.041s -> 492.508s (1.33%) |
|
Perf regressions, boo. The code in question: The Is it even valid to skip doc comments? Maybe it's ok because (a) hashing is only needed for incremental compilation, (b) doc comments only affect rustdoc builds, and (c) rustdoc doesn't use incremental? Hmm, still feels dubious. |
|
Doc comments do end up in the crate metadata, so just skipping them for incr comp is probably wrong. |
|
There is also a query I will update the description and then I think we should take the perf hit for improved correctness. |
795a1d3 to
ba7e441
Compare
This impl skips: - All doc comments - A handful of other attributes, mostly `rustc_*` ones related to incremental compilation testing. This skipping originated in rust-lang#36025 and was extended a couple of times, e.g. in rust-lang#36370. Those PRs don't have any explanation of why the skipping exists. Perhaps the reasoning was that doc comments should only affect rustdoc and rustdoc doesn't use incremental compilation? But doc comments end up in metadata, and there is a query `attrs_for_def` that returns a `&'tcx [hir::Attribute]`. So skipping some attributes just seems plainly wrong. This commit removes the impl, which means `[hir::Attribute]` hashing falls back to the default impl for `[T]`. This has no noticeable effect on the test suite. It does slightly hurt performance, because of the doc comments. This perf regression seems worth it for the correctness benefits.
ba7e441 to
cc74de3
Compare
|
As per the PR description and discussion in the comments, the current behaviour of skipping doc comments (and certain other comments) is very likely wrong, and it's worth the small perf hit to correct it. @rustbot label: +perf-regression-triaged |
|
|
@JonathanBrouwer I have updated the PR description and commit message with the new information. The conclusion being that the current behaviour is probably wrong, and it's worth taking the small perf hit to fix it. |
I guess the alternative to the current implementation would be removing doc comments from crate metadata. (And could you also move the issue numbers out of the commit descriptions to make rustbot happy?) |
|
Started a PR here to see which tests fails, and what the perf effect would be: #155001 I just remembered they don't only end up in the crate metadata, but probably also in the incremental cache, so I think not hashing them is probably wrong either way... But that PR might mitigate the perf effect which is relatively small so we can take it, but not ideal |
There was a problem hiding this comment.
That idea from my PR seems to be hopeless for now, will experiment with that more when I have more time.
I would really like to see an incremental test in this PR tho, I've tried for a little bit to make one but I'm not managing to find any incremental test that fails. I don't understand why this test doesn't fail:
//@ check-pass
//@ revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
//@ compile-flags: -Z query-dep-graph -O
//@ [cfail1]compile-flags: -Zincremental-ignore-spans
//@ [cfail2]compile-flags: -Zincremental-ignore-spans
//@ [cfail3]compile-flags: -Zincremental-ignore-spans
//@ ignore-backends: gcc
#![allow(warnings)]
#![feature(rustc_attrs)]
#![feature(linkage)]
#![feature(thread_local)]
#![crate_type="rlib"]
// Change static visibility
#[cfg(any(cfail1,cfail4))]
pub static ITEM: u8 = 0;
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg="cfail2")]
#[rustc_clean(cfg="cfail3")]
#[rustc_clean(cfg="cfail5")]
#[rustc_clean(cfg="cfail6")]
/// This item has a doc-comment
pub static ITEM: u8 = 0;|
Reminder, once the PR becomes ready for a review, use |
|
I'm surprised there is no change in rmeta size. Sad. :-/ |
Yes, for Edit: That was already said on your PR trying this. |
|
@JonathanBrouwer: I see you've used
I'm not sure why, but changes in attributes aren't detected by this incremental testing. And this lack of detection cannot be due to the I looked at the history of the test. The attribute-changes-do-not-affect-hash behaviour was introduced in 6b5d2de, in the very large #79519, which has this description:
I don't see any further discussion explaining why this is legitimate. Maybe we need @cjgillot's input here! |
View all comments
This impl skips:
rustc_*ones related to incremental compilation testing.This skipping originated in #36025 and was extended a couple of times, e.g. in #36370. Those PRs don't have any explanation of why the skipping exists. Perhaps the reasoning was that doc comments should only affect rustdoc and rustdoc doesn't use incremental compilation? But doc comments end up in metadata, and there is a query
attrs_for_defthat returns a&'tcx [hir::Attribute]. So skipping some attributes just seems plainly wrong.This commit removes the impl, which means
[hir::Attribute]hashing falls back to the default impl for[T]. This has no noticeable effect on the test suite. It does slightly hurt performance, because of the doc comments. This perf regression seems worth it for the correctness benefits.