]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: add gc_event
authorSlava Pestov <slava@shill.local>
Tue, 27 Oct 2009 03:12:44 +0000 (22:12 -0500)
committerSlava Pestov <slava@shill.local>
Tue, 27 Oct 2009 03:12:44 +0000 (22:12 -0500)
vm/gc.cpp
vm/gc.hpp

index dd881c257b43378550a976dd254dd1cb47b7d1c5..be505b4ef92b974fd3f499e736ab5d69a2279107 100755 (executable)
--- a/vm/gc.cpp
+++ b/vm/gc.cpp
@@ -7,6 +7,87 @@ gc_state::gc_state(gc_op op_) : op(op_), start_time(current_micros()) {}
 
 gc_state::~gc_state() {}
 
+gc_event::gc_event(gc_op op_, factor_vm *parent) :
+       op(op_),
+       start_time(current_micros()),
+       card_scan_time(0),
+       data_sweep_time(0),
+       code_sweep_time(0),
+       compaction_time(0)
+{
+       nursery_size_before = parent->nursery.occupied_space();
+       aging_size_before = parent->data->aging->occupied_space();
+       tenured_size_before = parent->data->tenured->occupied_space();
+       tenured_free_block_count_before = parent->data->tenured->free_blocks.free_block_count;
+       code_size_before = parent->code->allocator->occupied_space();
+       code_free_block_count_before = parent->code->allocator->free_blocks.free_block_count;
+       start_time = current_micros();
+}
+
+void gc_event::started_card_scan()
+{
+       card_scan_time = current_micros();
+}
+
+void gc_event::ended_card_scan(cell cards_scanned_, cell decks_scanned_)
+{
+       cards_scanned += cards_scanned_;
+       decks_scanned += decks_scanned_;
+       card_scan_time = (card_scan_time - current_micros());
+}
+
+void gc_event::started_code_scan()
+{
+       code_scan_time = current_micros();
+}
+
+void gc_event::ended_code_scan(cell code_blocks_scanned_)
+{
+       code_blocks_scanned += code_blocks_scanned_;
+       code_scan_time = (code_scan_time - current_micros());
+}
+
+void gc_event::started_data_sweep()
+{
+       data_sweep_time = current_micros();
+}
+
+void gc_event::ended_data_sweep()
+{
+       data_sweep_time = (data_sweep_time - current_micros());
+}
+
+void gc_event::started_code_sweep()
+{
+       code_sweep_time = current_micros();
+}
+
+void gc_event::ended_code_sweep()
+{
+       code_sweep_time = (code_sweep_time - current_micros());
+}
+
+void gc_event::started_compaction()
+{
+       compaction_time = current_micros();
+}
+
+void gc_event::ended_compaction()
+{
+       compaction_time = (compaction_time - current_micros());
+}
+
+void gc_event::ended_gc(factor_vm *parent)
+{
+       nursery_size_after = parent->nursery.occupied_space();
+       aging_size_after = parent->data->aging->occupied_space();
+       tenured_size_after = parent->data->tenured->occupied_space();
+       tenured_free_block_count_after = parent->data->tenured->free_blocks.free_block_count;
+       code_size_after = parent->code->allocator->occupied_space();
+       code_free_block_count_after = parent->code->allocator->free_blocks.free_block_count;
+       total_time = current_micros() - start_time;
+}
+
 void factor_vm::update_code_heap_for_minor_gc(std::set<code_block *> *remembered_set)
 {
        /* The youngest generation that any code block can now reference */
index dff9923f6ef4c360471f33a705602079826dcc11..e6713af52f25d70784e45738d527b4530ce15375 100755 (executable)
--- a/vm/gc.hpp
+++ b/vm/gc.hpp
@@ -19,6 +19,45 @@ struct gc_state {
        ~gc_state();
 };
 
+struct gc_event {
+       gc_op op;
+       cell nursery_size_before;
+       cell aging_size_before;
+       cell tenured_size_before;
+       cell tenured_free_block_count_before;
+       cell code_size_before;
+       cell code_free_block_count_before;
+       cell nursery_size_after;
+       cell aging_size_after;
+       cell tenured_size_after;
+       cell tenured_free_block_count_after;
+       cell code_size_after;
+       cell code_free_block_count_after;
+       cell cards_scanned;
+       cell decks_scanned;
+       cell code_blocks_scanned;
+       u64 start_time;
+       cell total_time;
+       cell card_scan_time;
+       cell code_scan_time;
+       cell data_sweep_time;
+       cell code_sweep_time;
+       cell compaction_time;
+
+       explicit gc_event(gc_op op_, factor_vm *parent);
+       void started_card_scan();
+       void ended_card_scan(cell cards_scanned_, cell decks_scanned_);
+       void started_code_scan();
+       void ended_code_scan(cell code_blocks_scanned_);
+       void started_data_sweep();
+       void ended_data_sweep();
+       void started_code_sweep();
+       void ended_code_sweep();
+       void started_compaction();
+       void ended_compaction();
+       void ended_gc(factor_vm *parent);
+};
+
 VM_C_API void inline_gc(cell *gc_roots_base, cell gc_roots_size, factor_vm *parent);
 
 }