Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Unified Diff: src/heap/gc-tracer.cc

Issue 2493803002: [heap] Add basic infrastructure for Minor Mark-Compact collector (Closed)
Patch Set: Addressed comment Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/gc-tracer.h ('k') | src/heap/heap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/gc-tracer.cc
diff --git a/src/heap/gc-tracer.cc b/src/heap/gc-tracer.cc
index 49f687990b8689e446f6192ae6c9a5f3e6e0777d..703b57b2b3c6672f16a4ddfdf090a2b52e86f5b8 100644
--- a/src/heap/gc-tracer.cc
+++ b/src/heap/gc-tracer.cc
@@ -84,28 +84,17 @@ GCTracer::Event::Event(Type type, GarbageCollectionReason gc_reason,
}
}
-
const char* GCTracer::Event::TypeName(bool short_name) const {
switch (type) {
case SCAVENGER:
- if (short_name) {
- return "s";
- } else {
- return "Scavenge";
- }
+ return (short_name) ? "s" : "Scavenge";
case MARK_COMPACTOR:
case INCREMENTAL_MARK_COMPACTOR:
- if (short_name) {
- return "ms";
- } else {
- return "Mark-sweep";
- }
+ return (short_name) ? "ms" : "Mark-sweep";
+ case MINOR_MARK_COMPACTOR:
+ return (short_name) ? "mmc" : "Minor Mark-Compact";
case START:
- if (short_name) {
- return "st";
- } else {
- return "Start";
- }
+ return (short_name) ? "st" : "Start";
}
return "Unknown Event Type";
}
@@ -116,6 +105,7 @@ GCTracer::GCTracer(Heap* heap)
previous_(current_),
incremental_marking_bytes_(0),
incremental_marking_duration_(0.0),
+ incremental_marking_start_time_(0.0),
recorded_incremental_marking_speed_(0.0),
allocation_time_ms_(0.0),
new_space_allocation_counter_bytes_(0),
@@ -140,8 +130,8 @@ void GCTracer::ResetForTesting() {
new_space_allocation_in_bytes_since_gc_ = 0.0;
old_generation_allocation_in_bytes_since_gc_ = 0.0;
combined_mark_compact_speed_cache_ = 0.0;
- recorded_scavenges_total_.Reset();
- recorded_scavenges_survived_.Reset();
+ recorded_minor_gcs_total_.Reset();
+ recorded_minor_gcs_survived_.Reset();
recorded_compactions_.Reset();
recorded_mark_compacts_.Reset();
recorded_incremental_mark_compacts_.Reset();
@@ -163,15 +153,22 @@ void GCTracer::Start(GarbageCollector collector,
SampleAllocation(start_time, heap_->NewSpaceAllocationCounter(),
heap_->OldGenerationAllocationCounter());
- if (collector == SCAVENGER) {
- current_ = Event(Event::SCAVENGER, gc_reason, collector_reason);
- } else if (collector == MARK_COMPACTOR) {
- if (heap_->incremental_marking()->WasActivated()) {
+ switch (collector) {
+ case SCAVENGER:
+ current_ = Event(Event::SCAVENGER, gc_reason, collector_reason);
+ break;
+ case MINOR_MARK_COMPACTOR:
current_ =
- Event(Event::INCREMENTAL_MARK_COMPACTOR, gc_reason, collector_reason);
- } else {
- current_ = Event(Event::MARK_COMPACTOR, gc_reason, collector_reason);
- }
+ Event(Event::MINOR_MARK_COMPACTOR, gc_reason, collector_reason);
+ break;
+ case MARK_COMPACTOR:
+ if (heap_->incremental_marking()->WasActivated()) {
+ current_ = Event(Event::INCREMENTAL_MARK_COMPACTOR, gc_reason,
+ collector_reason);
+ } else {
+ current_ = Event(Event::MARK_COMPACTOR, gc_reason, collector_reason);
+ }
+ break;
}
current_.reduce_memory = heap_->ShouldReduceMemory();
@@ -194,7 +191,7 @@ void GCTracer::Start(GarbageCollector collector,
Counters* counters = heap_->isolate()->counters();
- if (collector == SCAVENGER) {
+ if (Heap::IsYoungGenerationCollector(collector)) {
counters->scavenge_reason()->AddSample(static_cast<int>(gc_reason));
} else {
counters->mark_compact_reason()->AddSample(static_cast<int>(gc_reason));
@@ -220,15 +217,16 @@ void GCTracer::ResetIncrementalMarkingCounters() {
void GCTracer::Stop(GarbageCollector collector) {
start_counter_--;
if (start_counter_ != 0) {
- heap_->isolate()->PrintWithTimestamp(
- "[Finished reentrant %s during %s.]\n",
- collector == SCAVENGER ? "Scavenge" : "Mark-sweep",
- current_.TypeName(false));
+ heap_->isolate()->PrintWithTimestamp("[Finished reentrant %s during %s.]\n",
+ Heap::CollectorName(collector),
+ current_.TypeName(false));
return;
}
DCHECK(start_counter_ >= 0);
DCHECK((collector == SCAVENGER && current_.type == Event::SCAVENGER) ||
+ (collector == MINOR_MARK_COMPACTOR &&
+ current_.type == Event::MINOR_MARK_COMPACTOR) ||
(collector == MARK_COMPACTOR &&
(current_.type == Event::MARK_COMPACTOR ||
current_.type == Event::INCREMENTAL_MARK_COMPACTOR)));
@@ -250,36 +248,45 @@ void GCTracer::Stop(GarbageCollector collector) {
double duration = current_.end_time - current_.start_time;
- if (current_.type == Event::SCAVENGER) {
- recorded_scavenges_total_.Push(
- MakeBytesAndDuration(current_.new_space_object_size, duration));
- recorded_scavenges_survived_.Push(MakeBytesAndDuration(
- current_.survived_new_space_object_size, duration));
- } else if (current_.type == Event::INCREMENTAL_MARK_COMPACTOR) {
- current_.incremental_marking_bytes = incremental_marking_bytes_;
- current_.incremental_marking_duration = incremental_marking_duration_;
- for (int i = 0; i < Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) {
- current_.incremental_marking_scopes[i] = incremental_marking_scopes_[i];
- current_.scopes[i] = incremental_marking_scopes_[i].duration;
- }
- RecordIncrementalMarkingSpeed(current_.incremental_marking_bytes,
- current_.incremental_marking_duration);
- recorded_incremental_mark_compacts_.Push(
- MakeBytesAndDuration(current_.start_object_size, duration));
- ResetIncrementalMarkingCounters();
- combined_mark_compact_speed_cache_ = 0.0;
- } else {
- DCHECK_EQ(0u, current_.incremental_marking_bytes);
- DCHECK_EQ(0, current_.incremental_marking_duration);
- recorded_mark_compacts_.Push(
- MakeBytesAndDuration(current_.start_object_size, duration));
- ResetIncrementalMarkingCounters();
- combined_mark_compact_speed_cache_ = 0.0;
+ switch (current_.type) {
+ case Event::SCAVENGER:
+ case Event::MINOR_MARK_COMPACTOR:
+ recorded_minor_gcs_total_.Push(
+ MakeBytesAndDuration(current_.new_space_object_size, duration));
+ recorded_minor_gcs_survived_.Push(MakeBytesAndDuration(
+ current_.survived_new_space_object_size, duration));
+ break;
+ case Event::INCREMENTAL_MARK_COMPACTOR:
+ current_.incremental_marking_bytes = incremental_marking_bytes_;
+ current_.incremental_marking_duration = incremental_marking_duration_;
+ for (int i = 0; i < Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) {
+ current_.incremental_marking_scopes[i] = incremental_marking_scopes_[i];
+ current_.scopes[i] = incremental_marking_scopes_[i].duration;
+ }
+ RecordIncrementalMarkingSpeed(current_.incremental_marking_bytes,
+ current_.incremental_marking_duration);
+ recorded_incremental_mark_compacts_.Push(
+ MakeBytesAndDuration(current_.start_object_size, duration));
+ ResetIncrementalMarkingCounters();
+ combined_mark_compact_speed_cache_ = 0.0;
+ break;
+ case Event::MARK_COMPACTOR:
+ DCHECK_EQ(0u, current_.incremental_marking_bytes);
+ DCHECK_EQ(0, current_.incremental_marking_duration);
+ recorded_mark_compacts_.Push(
+ MakeBytesAndDuration(current_.start_object_size, duration));
+ ResetIncrementalMarkingCounters();
+ combined_mark_compact_speed_cache_ = 0.0;
+ break;
+ case Event::START:
+ UNREACHABLE();
}
heap_->UpdateTotalGCTime(duration);
- if (current_.type == Event::SCAVENGER && FLAG_trace_gc_ignore_scavenger)
+ if ((current_.type == Event::SCAVENGER ||
+ current_.type == Event::MINOR_MARK_COMPACTOR) &&
+ FLAG_trace_gc_ignore_scavenger)
return;
if (FLAG_trace_gc_nvp) {
@@ -500,6 +507,15 @@ void GCTracer::PrintNVP() const {
NewSpaceAllocationThroughputInBytesPerMillisecond(),
ContextDisposalRateInMilliseconds());
break;
+ case Event::MINOR_MARK_COMPACTOR:
+ heap_->isolate()->PrintWithTimestamp(
+ "pause=%.1f "
+ "mutator=%.1f "
+ "gc=%s "
+ "reduce_memory=%d\n",
+ duration, spent_in_mutator, current_.TypeName(true),
+ current_.reduce_memory);
+ break;
case Event::MARK_COMPACTOR:
case Event::INCREMENTAL_MARK_COMPACTOR:
heap_->isolate()->PrintWithTimestamp(
@@ -721,9 +737,9 @@ double GCTracer::IncrementalMarkingSpeedInBytesPerMillisecond() const {
double GCTracer::ScavengeSpeedInBytesPerMillisecond(
ScavengeSpeedMode mode) const {
if (mode == kForAllObjects) {
- return AverageSpeed(recorded_scavenges_total_);
+ return AverageSpeed(recorded_minor_gcs_total_);
} else {
- return AverageSpeed(recorded_scavenges_survived_);
+ return AverageSpeed(recorded_minor_gcs_survived_);
}
}
« no previous file with comments | « src/heap/gc-tracer.h ('k') | src/heap/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698