Skip to content

Commit c092061

Browse files
Compact obj_free candidates in place
use retain_mut in process_obj_free_candidates instead of building a new Vec on every GC. This saves about 38MiB of peak RSS when running the Lobsters benchmark with 12 workers.
1 parent 078de90 commit c092061

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

‎gc/mmtk/src/weak_proc.rs‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,21 +133,17 @@ impl WeakProcessor {
133133
}
134134

135135
fn process_obj_free_candidates(obj_free_candidates: &mut Vec<ObjectReference>) {
136-
// Process obj_free
137-
let mut new_candidates = Vec::new();
138-
139-
for object in obj_free_candidates.iter().copied() {
136+
obj_free_candidates.retain_mut(|object| {
140137
if object.is_reachable() {
141-
// Forward and add back to the candidate list.
142138
let new_object = object.forward();
143139
trace!("Forwarding obj_free candidate: {object} -> {new_object}");
144-
new_candidates.push(new_object);
140+
*object = new_object;
141+
true
145142
} else {
146-
upcalls::call_obj_free(object);
143+
upcalls::call_obj_free(*object);
144+
false
147145
}
148-
}
149-
150-
*obj_free_candidates = new_candidates;
146+
});
151147
}
152148

153149
struct ProcessParallelObjFreeCandidates {

0 commit comments

Comments
 (0)