Skip to content

Commit ce0ba41

Browse files
authored
Aggregate live bytes info in on_gc_finished (#1292)
This PR moves the call to `aggregate_live_bytes_in_last_gc` from the `Release` work packet to `on_gc_finished`. Spaces may do release work in parallel with the `Release` work packet, and `aggregate_live_bytes_in_last_gc` accesses reserved pages of spaces. This leads to a data race. We observed the reserved pages in the collected live bytes stats to be larger than the actual reserved pages at the end of a GC, as some pages were not released yet.
1 parent 374ec2c commit ce0ba41

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/scheduler/gc_work.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,6 @@ impl<C: GCWorkContext + 'static> GCWork<C::VM> for Release<C> {
153153
let result = w.designated_work.push(Box::new(ReleaseCollector));
154154
debug_assert!(result.is_ok());
155155
}
156-
157-
if *mmtk.get_options().count_live_bytes_in_gc {
158-
let live_bytes = mmtk
159-
.scheduler
160-
.worker_group
161-
.get_and_clear_worker_live_bytes();
162-
*mmtk.state.live_bytes_in_last_gc.borrow_mut() =
163-
mmtk.aggregate_live_bytes_in_last_gc(live_bytes);
164-
}
165156
}
166157
}
167158

src/scheduler/scheduler.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,15 @@ impl<VM: VMBinding> GCWorkScheduler<VM> {
554554
probe!(mmtk, gc_end);
555555

556556
if *mmtk.get_options().count_live_bytes_in_gc {
557-
for (space_name, &stats) in mmtk.state.live_bytes_in_last_gc.borrow().iter() {
557+
// Aggregate the live bytes
558+
let live_bytes = mmtk
559+
.scheduler
560+
.worker_group
561+
.get_and_clear_worker_live_bytes();
562+
let mut live_bytes_in_last_gc = mmtk.state.live_bytes_in_last_gc.borrow_mut();
563+
*live_bytes_in_last_gc = mmtk.aggregate_live_bytes_in_last_gc(live_bytes);
564+
// Logging
565+
for (space_name, &stats) in live_bytes_in_last_gc.iter() {
558566
info!(
559567
"{} = {} pages ({:.1}% live)",
560568
space_name,

0 commit comments

Comments
 (0)