Commit 92859d3c authored by hpayer@chromium.org's avatar hpayer@chromium.org

Add finalize sweeping event to GCIdleTimeHandler.

BUG=
R=ulan@chromium.org

Review URL: https://codereview.chromium.org/479693004

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23302 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 77d06401
...@@ -10,7 +10,6 @@ namespace v8 { ...@@ -10,7 +10,6 @@ namespace v8 {
namespace internal { namespace internal {
const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9; const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9;
const size_t GCIdleTimeHandler::kMaxMarkCompactTimeInMs = 1000000;
size_t GCIdleTimeHandler::EstimateMarkingStepSize( size_t GCIdleTimeHandler::EstimateMarkingStepSize(
...@@ -30,8 +29,7 @@ size_t GCIdleTimeHandler::EstimateMarkingStepSize( ...@@ -30,8 +29,7 @@ size_t GCIdleTimeHandler::EstimateMarkingStepSize(
if (marking_step_size > kMaximumMarkingStepSize) if (marking_step_size > kMaximumMarkingStepSize)
return kMaximumMarkingStepSize; return kMaximumMarkingStepSize;
return static_cast<size_t>(marking_step_size * return static_cast<size_t>(marking_step_size * kConservativeTimeRatio);
GCIdleTimeHandler::kConservativeTimeRatio);
} }
...@@ -45,7 +43,7 @@ size_t GCIdleTimeHandler::EstimateMarkCompactTime( ...@@ -45,7 +43,7 @@ size_t GCIdleTimeHandler::EstimateMarkCompactTime(
} }
GCIdleTimeAction GCIdleTimeHandler::Compute(int idle_time_in_ms, GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms,
HeapState heap_state, HeapState heap_state,
GCTracer* gc_tracer) { GCTracer* gc_tracer) {
if (IsIdleRoundFinished()) { if (IsIdleRoundFinished()) {
...@@ -58,8 +56,8 @@ GCIdleTimeAction GCIdleTimeHandler::Compute(int idle_time_in_ms, ...@@ -58,8 +56,8 @@ GCIdleTimeAction GCIdleTimeHandler::Compute(int idle_time_in_ms,
if (heap_state.incremental_marking_stopped) { if (heap_state.incremental_marking_stopped) {
size_t speed = size_t speed =
static_cast<size_t>(gc_tracer->MarkCompactSpeedInBytesPerMillisecond()); static_cast<size_t>(gc_tracer->MarkCompactSpeedInBytesPerMillisecond());
if (idle_time_in_ms >= static_cast<int>(EstimateMarkCompactTime( if (idle_time_in_ms >=
heap_state.size_of_objects, speed))) { EstimateMarkCompactTime(heap_state.size_of_objects, speed)) {
// If there are no more than two GCs left in this idle round and we are // If there are no more than two GCs left in this idle round and we are
// allowed to do a full GC, then make those GCs full in order to compact // allowed to do a full GC, then make those GCs full in order to compact
// the code space. // the code space.
...@@ -76,6 +74,12 @@ GCIdleTimeAction GCIdleTimeHandler::Compute(int idle_time_in_ms, ...@@ -76,6 +74,12 @@ GCIdleTimeAction GCIdleTimeHandler::Compute(int idle_time_in_ms,
return GCIdleTimeAction::Nothing(); return GCIdleTimeAction::Nothing();
} }
} }
// TODO(hpayer): Estimate finalize sweeping time.
if (heap_state.sweeping_in_progress &&
idle_time_in_ms >= kMinTimeForFinalizeSweeping) {
return GCIdleTimeAction::FinalizeSweeping();
}
intptr_t speed = gc_tracer->IncrementalMarkingSpeedInBytesPerMillisecond(); intptr_t speed = gc_tracer->IncrementalMarkingSpeedInBytesPerMillisecond();
size_t step_size = size_t step_size =
static_cast<size_t>(EstimateMarkingStepSize(idle_time_in_ms, speed)); static_cast<size_t>(EstimateMarkingStepSize(idle_time_in_ms, speed));
......
...@@ -14,7 +14,8 @@ enum GCIdleTimeActionType { ...@@ -14,7 +14,8 @@ enum GCIdleTimeActionType {
DO_NOTHING, DO_NOTHING,
DO_INCREMENTAL_MARKING, DO_INCREMENTAL_MARKING,
DO_SCAVENGE, DO_SCAVENGE,
DO_FULL_GC DO_FULL_GC,
DO_FINALIZE_SWEEPING
}; };
...@@ -26,18 +27,21 @@ class GCIdleTimeAction { ...@@ -26,18 +27,21 @@ class GCIdleTimeAction {
result.parameter = 0; result.parameter = 0;
return result; return result;
} }
static GCIdleTimeAction IncrementalMarking(intptr_t step_size) { static GCIdleTimeAction IncrementalMarking(intptr_t step_size) {
GCIdleTimeAction result; GCIdleTimeAction result;
result.type = DO_INCREMENTAL_MARKING; result.type = DO_INCREMENTAL_MARKING;
result.parameter = step_size; result.parameter = step_size;
return result; return result;
} }
static GCIdleTimeAction Scavenge() { static GCIdleTimeAction Scavenge() {
GCIdleTimeAction result; GCIdleTimeAction result;
result.type = DO_SCAVENGE; result.type = DO_SCAVENGE;
result.parameter = 0; result.parameter = 0;
return result; return result;
} }
static GCIdleTimeAction FullGC() { static GCIdleTimeAction FullGC() {
GCIdleTimeAction result; GCIdleTimeAction result;
result.type = DO_FULL_GC; result.type = DO_FULL_GC;
...@@ -45,6 +49,13 @@ class GCIdleTimeAction { ...@@ -45,6 +49,13 @@ class GCIdleTimeAction {
return result; return result;
} }
static GCIdleTimeAction FinalizeSweeping() {
GCIdleTimeAction result;
result.type = DO_FINALIZE_SWEEPING;
result.parameter = 0;
return result;
}
GCIdleTimeActionType type; GCIdleTimeActionType type;
intptr_t parameter; intptr_t parameter;
}; };
...@@ -72,20 +83,25 @@ class GCIdleTimeHandler { ...@@ -72,20 +83,25 @@ class GCIdleTimeHandler {
static const size_t kInitialConservativeMarkCompactSpeed = 2 * MB; static const size_t kInitialConservativeMarkCompactSpeed = 2 * MB;
// Maximum mark-compact time returned by EstimateMarkCompactTime. // Maximum mark-compact time returned by EstimateMarkCompactTime.
static const size_t kMaxMarkCompactTimeInMs; static const size_t kMaxMarkCompactTimeInMs = 1000000;
// Minimum time to finalize sweeping phase. The main thread may wait for
// sweeper threads.
static const size_t kMinTimeForFinalizeSweeping = 100;
struct HeapState { struct HeapState {
int contexts_disposed; int contexts_disposed;
size_t size_of_objects; size_t size_of_objects;
bool incremental_marking_stopped; bool incremental_marking_stopped;
bool can_start_incremental_marking; bool can_start_incremental_marking;
bool sweeping_in_progress;
}; };
GCIdleTimeHandler() GCIdleTimeHandler()
: mark_compacts_since_idle_round_started_(0), : mark_compacts_since_idle_round_started_(0),
scavenges_since_last_idle_round_(0) {} scavenges_since_last_idle_round_(0) {}
GCIdleTimeAction Compute(int idle_time_in_ms, HeapState heap_state, GCIdleTimeAction Compute(size_t idle_time_in_ms, HeapState heap_state,
GCTracer* gc_tracer); GCTracer* gc_tracer);
void NotifyIdleMarkCompact() { void NotifyIdleMarkCompact() {
......
...@@ -4296,6 +4296,8 @@ bool Heap::IdleNotification(int idle_time_in_ms) { ...@@ -4296,6 +4296,8 @@ bool Heap::IdleNotification(int idle_time_in_ms) {
heap_state.incremental_marking_stopped = incremental_marking()->IsStopped(); heap_state.incremental_marking_stopped = incremental_marking()->IsStopped();
// TODO(ulan): Start incremental marking only for large heaps. // TODO(ulan): Start incremental marking only for large heaps.
heap_state.can_start_incremental_marking = true; heap_state.can_start_incremental_marking = true;
heap_state.sweeping_in_progress =
mark_compact_collector()->sweeping_in_progress();
GCIdleTimeAction action = GCIdleTimeAction action =
gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state, tracer()); gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state, tracer());
...@@ -4321,18 +4323,12 @@ bool Heap::IdleNotification(int idle_time_in_ms) { ...@@ -4321,18 +4323,12 @@ bool Heap::IdleNotification(int idle_time_in_ms) {
case DO_SCAVENGE: case DO_SCAVENGE:
CollectGarbage(NEW_SPACE, "idle notification: scavenge"); CollectGarbage(NEW_SPACE, "idle notification: scavenge");
break; break;
case DO_FINALIZE_SWEEPING:
mark_compact_collector()->EnsureSweepingCompleted();
case DO_NOTHING: case DO_NOTHING:
result = true; result = true;
break; break;
} }
// If the IdleNotifcation is called with a large hint we will wait for
// the sweepter threads here.
// TODO(ulan): move this in GCIdleTimeHandler.
const int kMinHintForFullGC = 100;
if (idle_time_in_ms >= kMinHintForFullGC &&
mark_compact_collector()->sweeping_in_progress()) {
mark_compact_collector()->EnsureSweepingCompleted();
}
return result; return result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment