Skip to content

Commit

Permalink
swiper: no need to compute live bytes for young pages anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
dinfuehr committed Jan 7, 2024
1 parent 27648c4 commit 5c8ebb5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 32 deletions.
16 changes: 8 additions & 8 deletions dora-runtime/src/gc/swiper/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,12 @@ impl HeapController {
}

pub fn full_compute_forward(&self) -> Numbers {
let values: Vec<_> = self.full_phases.iter().map(|x| x.compute_forward).collect();
let values: Vec<_> = self.full_phases.iter().map(|x| x.sweep).collect();
calculate_numbers(&values)
}

pub fn full_compute_forward_all(&self) -> AllNumbers {
AllNumbers(self.full_phases.iter().map(|x| x.compute_forward).collect())
AllNumbers(self.full_phases.iter().map(|x| x.sweep).collect())
}

pub fn full_update_refs(&self) -> Numbers {
Expand All @@ -265,12 +265,12 @@ impl HeapController {
}

pub fn full_relocate(&self) -> Numbers {
let values: Vec<_> = self.full_phases.iter().map(|x| x.relocate).collect();
let values: Vec<_> = self.full_phases.iter().map(|x| x.evacuate).collect();
calculate_numbers(&values)
}

pub fn full_relocate_all(&self) -> AllNumbers {
AllNumbers(self.full_phases.iter().map(|x| x.relocate).collect())
AllNumbers(self.full_phases.iter().map(|x| x.evacuate).collect())
}

pub fn full_reset_cards(&self) -> Numbers {
Expand Down Expand Up @@ -386,9 +386,9 @@ pub type SharedHeapConfig = Arc<Mutex<HeapController>>;
#[derive(Clone)]
pub struct FullCollectorPhases {
pub marking: f32,
pub compute_forward: f32,
pub sweep: f32,
pub evacuate: f32,
pub update_refs: f32,
pub relocate: f32,
pub reset_cards: f32,
pub total: f32,
}
Expand All @@ -397,9 +397,9 @@ impl FullCollectorPhases {
pub fn new() -> FullCollectorPhases {
FullCollectorPhases {
marking: 0f32,
compute_forward: 0f32,
sweep: 0f32,
update_refs: 0f32,
relocate: 0f32,
evacuate: 0f32,
reset_cards: 0f32,
total: 0f32,
}
Expand Down
25 changes: 1 addition & 24 deletions dora-runtime/src/gc/swiper/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ pub struct FullCollector<'a> {
card_table: &'a CardTable,
crossing_map: &'a CrossingMap,
readonly_space: &'a Space,
young_evacuated_pages: Vec<(Page, usize)>,

top: Address,
current_limit: Address,
Expand Down Expand Up @@ -76,7 +75,6 @@ impl<'a> FullCollector<'a> {
card_table,
crossing_map,
readonly_space,
young_evacuated_pages: Vec::new(),

top: old_total.start(),
current_limit: old_total.start(),
Expand Down Expand Up @@ -133,7 +131,6 @@ impl<'a> FullCollector<'a> {
}
}

self.select_evacuated_pages();
self.sweep();
self.evacuate();
self.update_references();
Expand Down Expand Up @@ -169,26 +166,6 @@ impl<'a> FullCollector<'a> {
});
}

fn select_evacuated_pages(&mut self) {
for page in self.young.pages() {
let live = self.compute_live_on_page(page);

if live > 0 {
self.young_evacuated_pages.push((page, live));
}
}
}

fn compute_live_on_page(&self, page: Page) -> usize {
let mut live = 0;
walk_region(self.vm, page.object_area(), |obj, _addr, size| {
if obj.header().is_marked() {
live += size;
}
});
live
}

fn update_references(&mut self) {
for page in self.old_protected.pages() {
walk_region(self.vm, page.object_area(), |object, _addr, _size| {
Expand Down Expand Up @@ -309,7 +286,7 @@ impl<'a> FullCollector<'a> {
fn evacuate(&mut self) {
self.old_protected.fill_alloc_page();

for (page, _) in self.young_evacuated_pages.clone() {
for page in self.young.pages() {
self.evacuate_page(page);
}
}
Expand Down

0 comments on commit 5c8ebb5

Please sign in to comment.