-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Don't recurse into allocations, use a global table instead #49833
Conversation
Your PR failed on Travis (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.
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 |
66dc729
to
efbb574
Compare
@@ -277,6 +280,31 @@ impl<'sess> OnDiskCache<'sess> { | |||
diagnostics_index | |||
}; | |||
|
|||
let interpret_alloc_index = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exact code exists twice, once for on_disk_cache
and once for rustc_metadata::encoder
. Not sure how to dedup.
LGTM |
src/librustc_metadata/schema.rs
Outdated
@@ -207,6 +207,7 @@ pub struct CrateRoot { | |||
pub impls: LazySeq<TraitImpls>, | |||
pub exported_symbols: EncodedExportedSymbols, | |||
pub wasm_custom_sections: LazySeq<DefIndex>, | |||
pub interpret_alloc_index: Vec<u32>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm seeing ICEs inside the deserialize impl for this field in 4 stage 2 run-pass tests with aux builds. I can't reproduce on stage 1 and Travis also takes it. Maybe there's some stale data where crates are loaded that were compiled without this field?
Also: should this be LazySeq?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have ignore_git
set (which is the default now), incompatible metadata won't be detected. I think I had this issue with test auxiliary crates. And yes, please make it a LazySeq<u32>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it into a LazySeq
, now I'm seeing the failures on stage 1, too. ignore_git
doesn't change anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The failure seems to be in the deserialization in the field after interpret_alloc_index
.
Your PR failed on Travis (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.
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 |
8c4d438
to
c10c9d3
Compare
☔ The latest upstream changes (presumably #49558) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @oli-obk! Looks great.
I'm probably overlooking something: Where are the allocations for statics encoded?
} else if let Some(did) = tcx.interpret_interner.get_corresponding_static_def_id(alloc_id) { | ||
// extern "C" statics don't have allocations, just encode its def_id | ||
EXTERN_STATIC_DISCRIMINANT.encode(encoder)?; | ||
} else if let Some(did) = tcx.interpret_interner.get_static(alloc_id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be moved up in order not to always hit the get_alloc
branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd assume that the get_alloc
branch is the most common. Also both get_alloc
and get_static
are just HashMap
lookups.
entry.insert(pos); | ||
None | ||
}, | ||
let index = if self.interpret_alloc_ids.insert(*alloc_id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need both interpret_alloc_ids
and interpret_allocs
? Or could just use interpret_allocs.contains_key()
instead of interpret_alloc_ids.contains()
? You might also be able to use the entry API here, so that there is just one hashtable lookup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could work
src/librustc/mir/interpret/mod.rs
Outdated
// extern "C" statics don't have allocations, just encode its def_id | ||
EXTERN_STATIC_DISCRIMINANT.encode(encoder)?; | ||
} else if let Some(did) = tcx.interpret_interner.get_static(alloc_id) { | ||
// referring to statics doesn't need to know about their allocations, just hash the DefId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/hash/encode ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha yea, this is actual copy paste
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AllocId
for a static does not point to the actual static's Allocation
anymore. Instead it works like function pointers, it's just an ID that you can use to get at the DefId
of the static. To get at the Allocation
of a static, you need to run the const_eval
query.
src/librustc/mir/interpret/mod.rs
Outdated
// extern "C" statics don't have allocations, just encode its def_id | ||
EXTERN_STATIC_DISCRIMINANT.encode(encoder)?; | ||
} else if let Some(did) = tcx.interpret_interner.get_static(alloc_id) { | ||
// referring to statics doesn't need to know about their allocations, just hash the DefId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha yea, this is actual copy paste
} else if let Some(did) = tcx.interpret_interner.get_corresponding_static_def_id(alloc_id) { | ||
// extern "C" statics don't have allocations, just encode its def_id | ||
EXTERN_STATIC_DISCRIMINANT.encode(encoder)?; | ||
} else if let Some(did) = tcx.interpret_interner.get_static(alloc_id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd assume that the get_alloc
branch is the most common. Also both get_alloc
and get_static
are just HashMap
lookups.
entry.insert(pos); | ||
None | ||
}, | ||
let index = if self.interpret_alloc_ids.insert(*alloc_id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could work
OK, so the |
Exactly. It's a little extreme, but forward compatible to allow statics to refer to the inside of other statics in the future. Also much harder to get wrong, because you can't accidentally get at the static A: (i32, u32) = (42, 43);
static B: &'static u32 = &A.1; |
OK, that makes sense to me then. It also explains why the ordering in It would be great if you could try to get rid of the |
c10c9d3
to
9fee6ec
Compare
Your PR failed on Travis (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.
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 |
9fee6ec
to
2d00f2d
Compare
☔ The latest upstream changes (presumably #49396) made this pull request unmergeable. Please resolve the merge conflicts. |
2d00f2d
to
7f7d4c3
Compare
Rebased and addressed all review comments |
I got two "lgtm", so let's get this moving (beta needs this) @bors r=michaelwoerister |
📌 Commit 7f7d4c3 has been approved by |
…woerister Don't recurse into allocations, use a global table instead r? @michaelwoerister fixes #49663
☀️ Test successful - status-appveyor, status-travis |
Marking as beta-accepted, with some reservations due to the size of the PR. But since there's already a bors run for a slew of beta backports that includes this currently in progress (due to a process failure), and @michaelwoerister says leaving this out will break incremental compilation.... |
Backported in #50027 |
r? @michaelwoerister
fixes #49663