Commit 309c082a authored by hpayer's avatar hpayer Committed by Commit bot

Shrink new space and uncommit from space in idle notification during long idle times.

BUG=chromium:481811
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#28107}
parent bb940247
...@@ -4535,17 +4535,8 @@ void Heap::MakeHeapIterable() { ...@@ -4535,17 +4535,8 @@ void Heap::MakeHeapIterable() {
} }
void Heap::IdleMarkCompact(const char* message) { void Heap::ReduceNewSpaceSize(bool is_long_idle_notification) {
bool uncommit = false; if (is_long_idle_notification) {
if (gc_count_at_last_idle_gc_ == gc_count_) {
// No GC since the last full GC, the mutator is probably not active.
isolate_->compilation_cache()->Clear();
uncommit = true;
}
CollectAllGarbage(kReduceMemoryFootprintMask, message);
gc_idle_time_handler_.NotifyIdleMarkCompact();
gc_count_at_last_idle_gc_ = gc_count_;
if (uncommit) {
new_space_.Shrink(); new_space_.Shrink();
UncommitFromSpace(); UncommitFromSpace();
} }
...@@ -4553,7 +4544,8 @@ void Heap::IdleMarkCompact(const char* message) { ...@@ -4553,7 +4544,8 @@ void Heap::IdleMarkCompact(const char* message) {
bool Heap::TryFinalizeIdleIncrementalMarking( bool Heap::TryFinalizeIdleIncrementalMarking(
double idle_time_in_ms, size_t size_of_objects, bool is_long_idle_notification, double idle_time_in_ms,
size_t size_of_objects,
size_t final_incremental_mark_compact_speed_in_bytes_per_ms) { size_t final_incremental_mark_compact_speed_in_bytes_per_ms) {
if (FLAG_overapproximate_weak_closure && if (FLAG_overapproximate_weak_closure &&
(incremental_marking()->IsReadyToOverApproximateWeakClosure() || (incremental_marking()->IsReadyToOverApproximateWeakClosure() ||
...@@ -4570,6 +4562,7 @@ bool Heap::TryFinalizeIdleIncrementalMarking( ...@@ -4570,6 +4562,7 @@ bool Heap::TryFinalizeIdleIncrementalMarking(
static_cast<size_t>(idle_time_in_ms), size_of_objects, static_cast<size_t>(idle_time_in_ms), size_of_objects,
final_incremental_mark_compact_speed_in_bytes_per_ms))) { final_incremental_mark_compact_speed_in_bytes_per_ms))) {
CollectAllGarbage(kNoGCFlags, "idle notification: finalize incremental"); CollectAllGarbage(kNoGCFlags, "idle notification: finalize incremental");
ReduceNewSpaceSize(is_long_idle_notification);
return true; return true;
} }
return false; return false;
...@@ -4598,6 +4591,9 @@ bool Heap::IdleNotification(double deadline_in_seconds) { ...@@ -4598,6 +4591,9 @@ bool Heap::IdleNotification(double deadline_in_seconds) {
HistogramTimerScope idle_notification_scope( HistogramTimerScope idle_notification_scope(
isolate_->counters()->gc_idle_notification()); isolate_->counters()->gc_idle_notification());
double idle_time_in_ms = deadline_in_ms - MonotonicallyIncreasingTimeInMs(); double idle_time_in_ms = deadline_in_ms - MonotonicallyIncreasingTimeInMs();
bool is_long_idle_notification =
static_cast<size_t>(idle_time_in_ms) >
GCIdleTimeHandler::kMaxFrameRenderingIdleTime;
GCIdleTimeHandler::HeapState heap_state; GCIdleTimeHandler::HeapState heap_state;
heap_state.contexts_disposed = contexts_disposed_; heap_state.contexts_disposed = contexts_disposed_;
...@@ -4607,8 +4603,7 @@ bool Heap::IdleNotification(double deadline_in_seconds) { ...@@ -4607,8 +4603,7 @@ bool Heap::IdleNotification(double deadline_in_seconds) {
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.
intptr_t limit = old_generation_allocation_limit_; intptr_t limit = old_generation_allocation_limit_;
if (static_cast<size_t>(idle_time_in_ms) > if (is_long_idle_notification) {
GCIdleTimeHandler::kMaxFrameRenderingIdleTime) {
limit = idle_old_generation_allocation_limit_; limit = idle_old_generation_allocation_limit_;
} }
...@@ -4663,24 +4658,31 @@ bool Heap::IdleNotification(double deadline_in_seconds) { ...@@ -4663,24 +4658,31 @@ bool Heap::IdleNotification(double deadline_in_seconds) {
!mark_compact_collector_.marking_deque()->IsEmpty()); !mark_compact_collector_.marking_deque()->IsEmpty());
if (remaining_idle_time_in_ms > 0.0) { if (remaining_idle_time_in_ms > 0.0) {
action.additional_work = TryFinalizeIdleIncrementalMarking( action.additional_work = TryFinalizeIdleIncrementalMarking(
remaining_idle_time_in_ms, heap_state.size_of_objects, is_long_idle_notification, remaining_idle_time_in_ms,
heap_state.size_of_objects,
heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms); heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms);
} }
break; break;
} }
case DO_FULL_GC: { case DO_FULL_GC: {
if (is_long_idle_notification && gc_count_at_last_idle_gc_ == gc_count_) {
isolate_->compilation_cache()->Clear();
}
if (contexts_disposed_) { if (contexts_disposed_) {
HistogramTimerScope scope(isolate_->counters()->gc_context()); HistogramTimerScope scope(isolate_->counters()->gc_context());
CollectAllGarbage(kNoGCFlags, "idle notification: contexts disposed"); CollectAllGarbage(kNoGCFlags, "idle notification: contexts disposed");
gc_idle_time_handler_.NotifyIdleMarkCompact();
gc_count_at_last_idle_gc_ = gc_count_;
} else { } else {
IdleMarkCompact("idle notification: finalize idle round"); CollectAllGarbage(kReduceMemoryFootprintMask,
"idle notification: finalize idle round");
} }
gc_count_at_last_idle_gc_ = gc_count_;
ReduceNewSpaceSize(is_long_idle_notification);
gc_idle_time_handler_.NotifyIdleMarkCompact();
break; break;
} }
case DO_SCAVENGE: case DO_SCAVENGE:
CollectGarbage(NEW_SPACE, "idle notification: scavenge"); CollectGarbage(NEW_SPACE, "idle notification: scavenge");
ReduceNewSpaceSize(is_long_idle_notification);
break; break;
case DO_FINALIZE_SWEEPING: case DO_FINALIZE_SWEEPING:
mark_compact_collector()->EnsureSweepingCompleted(); mark_compact_collector()->EnsureSweepingCompleted();
......
...@@ -2069,11 +2069,11 @@ class Heap { ...@@ -2069,11 +2069,11 @@ class Heap {
void SelectScavengingVisitorsTable(); void SelectScavengingVisitorsTable();
void IdleMarkCompact(const char* message); void ReduceNewSpaceSize(bool is_long_idle_notification);
bool TryFinalizeIdleIncrementalMarking( bool TryFinalizeIdleIncrementalMarking(
double idle_time_in_ms, size_t size_of_objects, bool is_long_idle_notification, double idle_time_in_ms,
size_t mark_compact_speed_in_bytes_per_ms); size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms);
void ClearObjectStats(bool clear_last_time_stats = false); void ClearObjectStats(bool clear_last_time_stats = false);
...@@ -2117,6 +2117,7 @@ class Heap { ...@@ -2117,6 +2117,7 @@ class Heap {
IncrementalMarking incremental_marking_; IncrementalMarking incremental_marking_;
GCIdleTimeHandler gc_idle_time_handler_; GCIdleTimeHandler gc_idle_time_handler_;
unsigned int gc_count_at_last_idle_gc_; unsigned int gc_count_at_last_idle_gc_;
// These two counters are monotomically increasing and never reset. // These two counters are monotomically increasing and never reset.
......
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