-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Make re-export collection deterministic #65043
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
r? @Centril |
Looks good but r? @petrochenkov should really review this since resolve is their wheelhouse. :) |
I think we usually deal with this via collection into a Vec and sorting just before metadata serialization; that might be a better approach here? |
I personally feel that |
@jonas-schievink: Thanks, fixed |
We do have a StableMap in the data structures crate as of a recent PR, so maybe using that here would be better. It does not expose iteration order at all (lacking those methods entirely). But again, I'm fine landing this in the mean time. An indexmap seems like a reasonable answer too. |
Stable map looks unsuitable since |
That was my first reaction too. We actually have a method for visiting resolutions in a stable fashion ( |
@bors try @rust-timer queue |
⌛ Trying commit 2c9bf5f9320945e4fc29927e8de60dd2fad8172f with merge 9f13bf7d334cc30a5fbe83d0309ccf107c0d512e... |
This comment has been minimized.
This comment has been minimized.
Awaiting bors try build completion |
⌛ Trying commit 2c9bf5f9320945e4fc29927e8de60dd2fad8172f with merge 0e298d5daf4f422edf242c37161329ee79515942... |
Actually, I'm not sure that the insertion order itself is stable for the resolutions, if it's not, then |
Interesting. I'm pretty happy I reassigned this PR. :) |
☀️ Try build successful - checks-azure |
Queued 0e298d5daf4f422edf242c37161329ee79515942 with parent 032a53a, future comparison URL. |
We have |
@petrochenkov: This looks like a wash performance wise - a few minor speedups and a few minor slowdowns. I suspect that much of it is just noise. |
Yeah, I just wanted to check what performance impact |
@petrochenkov: All other things being equal, I think it's better to reduce the amount of non-determinism in the compiler. This issue was a pain to track down, and I'm worried that it might crop up again if we're relying on every caller using |
Let's check whether |
Looks like resolutions are added in stable order, so we can use an @Aaron1011 |
Previously, we were using an `FxHashMap` to collect module re-exports. However, re-exports end up getting serialized into crate metadata, which means that metadata generation was non-deterministic. This resulted in spurious error messages changes (e.g. PR rust-lang#64906) due to pretty-printing implicitly depending on the order of re-exports when computing the proper path to show to the user. See rust-lang#65042 for a long-term strategy to detect this kind of issue
2c9bf5f
to
33178a9
Compare
@petrochenkov Updated |
Now that `Resolutions` has a deterministic iteration order, it's no longer necessary to sort its entries before iterating over them
33178a9
to
add0a42
Compare
Thanks! |
📌 Commit add0a42 has been approved by |
…nkov Make re-export collection deterministic Fixes #65036 Previously, we were using an `FxHashMap` to collect module re-exports. However, re-exports end up getting serialized into crate metadata, which means that metadata generation was non-deterministic. This resulted in spurious error messages changes (e.g. PR #64906) due to pretty-printing implicitly depending on the order of re-exports when computing the proper path to show to the user. See #65042 for a long-term strategy to detect this kind of issue
☀️ Test successful - checks-azure |
Clarification to avoid spreading this myth further: |
@RalfJung: I meant 'non-deterministic with respect to platforms' - that is, the crate metadata order wouldn't look the same across different platforms. Sorry for the confusion. |
Fixes #65036
Previously, we were using an
FxHashMap
to collect module re-exports.However, re-exports end up getting serialized into crate metadata, which
means that metadata generation was non-deterministic. This resulted in
spurious error messages changes (e.g. PR #64906) due to pretty-printing
implicitly depending on the order of re-exports when computing the
proper path to show to the user.
See #65042 for a long-term strategy to detect this kind of issue