diff --git a/dora-runtime/src/gc/sweep.rs b/dora-runtime/src/gc/sweep.rs index d00eaf0f5..1355d96dc 100644 --- a/dora-runtime/src/gc/sweep.rs +++ b/dora-runtime/src/gc/sweep.rs @@ -167,24 +167,10 @@ struct MarkSweep<'a> { impl<'a> MarkSweep<'a> { fn collect(&mut self) { - let dev_verbose = self.vm.flags.gc_dev_verbose; - - if dev_verbose { - println!("Sweep GC: Phase 1 (marking)"); - } - self.mark(); self.iterate_weak_refs(); - if dev_verbose { - println!("Sweep GC: Phase 2 (sweep)"); - } - self.sweep(); - - if dev_verbose { - println!("Sweep GC: Stop"); - } } fn mark(&mut self) { diff --git a/dora-runtime/src/gc/swiper.rs b/dora-runtime/src/gc/swiper.rs index 7179a5faf..0def476a8 100644 --- a/dora-runtime/src/gc/swiper.rs +++ b/dora-runtime/src/gc/swiper.rs @@ -244,13 +244,7 @@ impl Swiper { rootset: &[Slot], threads: &[Arc], ) { - self.verify( - vm, - VerifierPhase::PreMinor, - CollectionKind::Minor, - "pre-minor", - &rootset, - ); + self.verify(vm, VerifierPhase::PreMinor, CollectionKind::Minor, &rootset); { let mut pool = self.threadpool.lock(); @@ -282,7 +276,6 @@ impl Swiper { vm, VerifierPhase::PostMinor, CollectionKind::Minor, - "post-minor", &rootset, ); } @@ -294,13 +287,7 @@ impl Swiper { threads: &[Arc], rootset: &[Slot], ) { - self.verify( - vm, - VerifierPhase::PreFull, - CollectionKind::Full, - "pre-full", - &rootset, - ); + self.verify(vm, VerifierPhase::PreFull, CollectionKind::Full, &rootset); { let mut collector = FullCollector::new( @@ -326,28 +313,11 @@ impl Swiper { } } - self.verify( - vm, - VerifierPhase::PostFull, - CollectionKind::Full, - "post-full", - &rootset, - ); + self.verify(vm, VerifierPhase::PostFull, CollectionKind::Full, &rootset); } - fn verify( - &self, - vm: &VM, - phase: VerifierPhase, - _kind: CollectionKind, - name: &str, - rootset: &[Slot], - ) { + fn verify(&self, vm: &VM, phase: VerifierPhase, _kind: CollectionKind, rootset: &[Slot]) { if vm.flags.gc_verify { - if vm.flags.gc_dev_verbose { - println!("GC: Verify {}", name); - } - let readonly_space = &vm.gc.readonly_space; let mut verifier = Verifier::new( @@ -363,10 +333,6 @@ impl Swiper { phase, ); verifier.verify(); - - if vm.flags.gc_dev_verbose { - println!("GC: Verify {} finished", name); - } } } @@ -467,19 +433,12 @@ impl Collector for Swiper { ); println!("GC stats: full-total={}", config.full_total_all()); println!("GC stats: full-marking={}", config.full_marking_all()); - println!( - "GC stats: full-compute-forward={}", - config.full_compute_forward_all() - ); + println!("GC stats: full-sweep={}", config.full_sweep_all()); println!( "GC stats: full-update-refs={}", config.full_update_refs_all() ); - println!("GC stats: full-relocate={}", config.full_relocate_all()); - println!( - "GC stats: full-reset-cards={}", - config.full_reset_cards_all() - ); + println!("GC stats: full-evacuate={}", config.full_relocate_all()); println!(""); println!( "GC stats: minor-collections={:.1}", @@ -511,10 +470,9 @@ impl Collector for Swiper { println!("\nFull:"); println!("\tMarking:\t{}", config.full_marking()); - println!("\tCompute Fwd:\t{}", config.full_compute_forward()); + println!("\tSweep:\t\t{}", config.full_sweep()); println!("\tUpdate Refs:\t{}", config.full_update_refs()); - println!("\tRelocate:\t{}", config.full_relocate()); - println!("\tReset Cards:\t{}", config.full_reset_cards()); + println!("\tEvacuate:\t{}", config.full_relocate()); println!("\tTotal:\t\t{}", config.full_total()); println!(""); diff --git a/dora-runtime/src/gc/swiper/controller.rs b/dora-runtime/src/gc/swiper/controller.rs index b9311c947..3f7aba7d3 100644 --- a/dora-runtime/src/gc/swiper/controller.rs +++ b/dora-runtime/src/gc/swiper/controller.rs @@ -246,12 +246,12 @@ impl HeapController { AllNumbers(self.full_phases.iter().map(|x| x.marking).collect()) } - pub fn full_compute_forward(&self) -> Numbers { + pub fn full_sweep(&self) -> Numbers { let values: Vec<_> = self.full_phases.iter().map(|x| x.sweep).collect(); calculate_numbers(&values) } - pub fn full_compute_forward_all(&self) -> AllNumbers { + pub fn full_sweep_all(&self) -> AllNumbers { AllNumbers(self.full_phases.iter().map(|x| x.sweep).collect()) } @@ -273,15 +273,6 @@ impl HeapController { AllNumbers(self.full_phases.iter().map(|x| x.evacuate).collect()) } - pub fn full_reset_cards(&self) -> Numbers { - let values: Vec<_> = self.full_phases.iter().map(|x| x.reset_cards).collect(); - calculate_numbers(&values) - } - - pub fn full_reset_cards_all(&self) -> AllNumbers { - AllNumbers(self.full_phases.iter().map(|x| x.reset_cards).collect()) - } - pub fn full_total(&self) -> Numbers { let values: Vec<_> = self.full_phases.iter().map(|x| x.total).collect(); calculate_numbers(&values) diff --git a/dora-runtime/src/gc/swiper/full.rs b/dora-runtime/src/gc/swiper/full.rs index 51c1f64e0..4dcd3d5d9 100644 --- a/dora-runtime/src/gc/swiper/full.rs +++ b/dora-runtime/src/gc/swiper/full.rs @@ -1,4 +1,5 @@ use std::sync::Arc; +use std::time::Instant; use parking_lot::MutexGuard; @@ -16,7 +17,6 @@ use crate::gc::{Address, GcReason, Region}; use crate::object::{Obj, VtblptrWordKind}; use crate::stdlib; use crate::threads::DoraThread; -use crate::timer::Timer; use crate::vm::{Trap, VM}; pub struct FullCollector<'a> { @@ -93,25 +93,9 @@ impl<'a> FullCollector<'a> { } pub fn collect(&mut self) { - let dev_verbose = self.vm.flags.gc_dev_verbose; - let stats = self.vm.flags.gc_stats; - - let mut timer = Timer::new(stats); - - if dev_verbose { - println!("Full GC: Start"); - } - - self.mark_live(); - - if stats { - let duration = timer.stop(); - self.phases.marking = duration; - } - - if dev_verbose { - println!("Full GC: Phase 1 (marking)"); - } + self.phases.marking = measure(self.vm, || { + self.mark_live(); + }); if self.vm.flags.gc_verify { verify_marking( @@ -121,28 +105,19 @@ impl<'a> FullCollector<'a> { self.large_space, self.heap, ); - - if stats { - timer.stop(); - } - - if dev_verbose { - println!("Full GC: Phase 1b (verify marking)"); - } } - self.sweep(); - self.evacuate(); - self.update_references(); + self.phases.sweep = measure(self.vm, || { + self.sweep(); + }); - if stats { - let duration = timer.stop(); - self.phases.reset_cards = duration; - } + self.phases.evacuate = measure(self.vm, || { + self.evacuate(); + }); - if dev_verbose { - println!("Full GC: Phase 5 (reset cards)"); - } + self.phases.update_refs = measure(self.vm, || { + self.update_references(); + }); self.young.reset_after_full_gc(self.vm); } @@ -403,3 +378,18 @@ fn verify_marking_object(obj_address: Address, heap: Region) { }); } } + +fn measure(vm: &VM, fct: F) -> f32 +where + F: FnOnce(), +{ + if vm.flags.gc_stats { + let start = Instant::now(); + fct(); + let duration = start.elapsed(); + duration.as_secs_f32() * 1000f32 + } else { + fct(); + 0.0f32 + } +} diff --git a/dora-runtime/src/gc/swiper/minor.rs b/dora-runtime/src/gc/swiper/minor.rs index a99e8e167..557f68406 100644 --- a/dora-runtime/src/gc/swiper/minor.rs +++ b/dora-runtime/src/gc/swiper/minor.rs @@ -112,18 +112,8 @@ impl<'a> MinorCollector<'a> { let to_committed = self.young.to_committed(); self.young_alloc = Some(YoungAlloc::new(to_committed)); - let dev_verbose = self.vm.flags.gc_dev_verbose; - - if dev_verbose { - println!("Minor GC: Worker threads started"); - } - self.run_threads(); - if dev_verbose { - println!("Minor GC: Worker threads finished"); - } - self.iterate_weak_refs(); let young_alloc = std::mem::replace(&mut self.young_alloc, None).expect("missing value"); diff --git a/dora-runtime/src/vm/flags.rs b/dora-runtime/src/vm/flags.rs index 0587d2133..66e7aa681 100644 --- a/dora-runtime/src/vm/flags.rs +++ b/dora-runtime/src/vm/flags.rs @@ -26,7 +26,6 @@ pub struct Flags { pub gc_stress_in_lazy_compile: bool, pub gc_stats: bool, pub gc_verbose: bool, - pub gc_dev_verbose: bool, pub gc_verify: bool, pub gc_worker: usize, pub gc_young_size: Option, diff --git a/dora/src/driver/cmd.rs b/dora/src/driver/cmd.rs index 74da456bc..238898e7d 100644 --- a/dora/src/driver/cmd.rs +++ b/dora/src/driver/cmd.rs @@ -35,7 +35,6 @@ Options: --gc-stress-minor Minor collection at every allocation. --gc-stats Print GC statistics. --gc-verbose Verbose GC. - --gc-dev-verbose Verbose GC for developers. --gc-verify Verify heap before and after collections. --gc-worker= Number of GC worker threads. --gc= Switch GC. Possible values: zero, copy, swiper (default). @@ -84,7 +83,6 @@ pub struct Args { pub gc_stress_minor: bool, pub gc_stats: bool, pub gc_verbose: bool, - pub gc_dev_verbose: bool, pub gc_verify: bool, pub gc_worker: usize, gc_young_size: Option, @@ -134,7 +132,6 @@ impl Default for Args { gc_stress_minor: false, gc_stats: false, gc_verbose: false, - gc_dev_verbose: false, gc_verify: false, gc_worker: 0, gc_young_size: None, @@ -249,8 +246,6 @@ pub fn parse_arguments() -> Result { args.gc_stats = true; } else if arg == "--gc-verbose" { args.gc_verbose = true; - } else if arg == "--gc-dev-verbose" { - args.gc_dev_verbose = true; } else if arg == "--gc-verify" { args.gc_verify = true; } else if arg.starts_with("--gc-worker=") { @@ -411,7 +406,6 @@ pub fn create_vm_args(args: &Args) -> VmArgs { gc_stress_minor: args.gc_stress_minor, gc_stats: args.gc_stats, gc_verbose: args.gc_verbose, - gc_dev_verbose: args.gc_dev_verbose, gc_verify: args.gc_verify, gc_worker: args.gc_worker, gc_young_size: args.gc_young_size,