Skip to content

Commit 0d473b1

Browse files
committed
Auto merge of #118073 - saethlin:gc-dead-allocs, r=RalfJung
Miri: GC the dead_alloc_map too dead_alloc_map is the last piece of state in the interpreter I can find that leaks. With this PR, all of the long-term memory growth I can find in Miri with programs that do things like run a big `loop {` or run property tests is attributable to some data structure properties in borrow tracking, and is _extremely_ slow. My only gripe with the commit in this PR is that I don't have a new test for it. I'd like to have a regression test for this, but it would have to be statistical I think because the peak memory of a process that Linux reports is not exactly the same run-to-run. Which means it would have to not be very sensitive to slow leaks (some guesswork suggests for acceptable CI time we would be checking for like 10% memory growth over a minute or two, which is still pretty fast IMO). Unless someone has a better idea for how to detect a regression, I think on balance I'm fine with manually keeping an eye on the memory use situation. r? RalfJung
2 parents c6c3be1 + 02d9362 commit 0d473b1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/provenance_gc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> {
195195
}
196196

197197
fn remove_unreachable_allocs(&mut self, allocs: FxHashSet<AllocId>) {
198-
let this = self.eval_context_ref();
198+
let this = self.eval_context_mut();
199199
let allocs = LiveAllocs {
200200
ecx: this,
201201
collected: allocs,
@@ -205,5 +205,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> {
205205
if let Some(borrow_tracker) = &this.machine.borrow_tracker {
206206
borrow_tracker.borrow_mut().remove_unreachable_allocs(&allocs);
207207
}
208+
this.remove_unreachable_allocs(&allocs.collected);
208209
}
209210
}

0 commit comments

Comments
 (0)