Revision: 23309
Author:   [email protected]
Date:     Fri Aug 22 12:32:12 2014 UTC
Log:      Re-land "Add finalize sweeping event to GCIdleTimeHandler."

BUG=
[email protected]

Review URL: https://codereview.chromium.org/496303002
https://code.google.com/p/v8/source/detail?r=23309

Modified:
 /branches/bleeding_edge/src/heap/gc-idle-time-handler.cc
 /branches/bleeding_edge/src/heap/gc-idle-time-handler.h
 /branches/bleeding_edge/src/heap/heap.cc

=======================================
--- /branches/bleeding_edge/src/heap/gc-idle-time-handler.cc Fri Aug 22 11:36:23 2014 UTC +++ /branches/bleeding_edge/src/heap/gc-idle-time-handler.cc Fri Aug 22 12:32:12 2014 UTC
@@ -11,6 +11,7 @@

 const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9;
 const size_t GCIdleTimeHandler::kMaxMarkCompactTimeInMs = 1000000;
+const size_t GCIdleTimeHandler::kMinTimeForFinalizeSweeping = 100;


 size_t GCIdleTimeHandler::EstimateMarkingStepSize(
@@ -30,8 +31,7 @@
   if (marking_step_size > kMaximumMarkingStepSize)
     return kMaximumMarkingStepSize;

-  return static_cast<size_t>(marking_step_size *
-                             GCIdleTimeHandler::kConservativeTimeRatio);
+  return static_cast<size_t>(marking_step_size * kConservativeTimeRatio);
 }


@@ -45,7 +45,7 @@
 }


-GCIdleTimeAction GCIdleTimeHandler::Compute(int idle_time_in_ms,
+GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms,
                                             HeapState heap_state,
                                             GCTracer* gc_tracer) {
   if (IsIdleRoundFinished()) {
@@ -58,8 +58,8 @@
   if (heap_state.incremental_marking_stopped) {
     size_t speed =
static_cast<size_t>(gc_tracer->MarkCompactSpeedInBytesPerMillisecond());
-    if (idle_time_in_ms >= static_cast<int>(EstimateMarkCompactTime(
-                               heap_state.size_of_objects, speed))) {
+    if (idle_time_in_ms >=
+        EstimateMarkCompactTime(heap_state.size_of_objects, speed)) {
// 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
       // the code space.
@@ -76,6 +76,12 @@
       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();
   size_t step_size =
       static_cast<size_t>(EstimateMarkingStepSize(idle_time_in_ms, speed));
=======================================
--- /branches/bleeding_edge/src/heap/gc-idle-time-handler.h Fri Aug 22 11:36:23 2014 UTC +++ /branches/bleeding_edge/src/heap/gc-idle-time-handler.h Fri Aug 22 12:32:12 2014 UTC
@@ -14,7 +14,8 @@
   DO_NOTHING,
   DO_INCREMENTAL_MARKING,
   DO_SCAVENGE,
-  DO_FULL_GC
+  DO_FULL_GC,
+  DO_FINALIZE_SWEEPING
 };


@@ -26,24 +27,34 @@
     result.parameter = 0;
     return result;
   }
+
   static GCIdleTimeAction IncrementalMarking(intptr_t step_size) {
     GCIdleTimeAction result;
     result.type = DO_INCREMENTAL_MARKING;
     result.parameter = step_size;
     return result;
   }
+
   static GCIdleTimeAction Scavenge() {
     GCIdleTimeAction result;
     result.type = DO_SCAVENGE;
     result.parameter = 0;
     return result;
   }
+
   static GCIdleTimeAction FullGC() {
     GCIdleTimeAction result;
     result.type = DO_FULL_GC;
     result.parameter = 0;
     return result;
   }
+
+  static GCIdleTimeAction FinalizeSweeping() {
+    GCIdleTimeAction result;
+    result.type = DO_FINALIZE_SWEEPING;
+    result.parameter = 0;
+    return result;
+  }

   GCIdleTimeActionType type;
   intptr_t parameter;
@@ -74,18 +85,23 @@
   // Maximum mark-compact time returned by EstimateMarkCompactTime.
   static const size_t kMaxMarkCompactTimeInMs;

+  // Minimum time to finalize sweeping phase. The main thread may wait for
+  // sweeper threads.
+  static const size_t kMinTimeForFinalizeSweeping;
+
   struct HeapState {
     int contexts_disposed;
     size_t size_of_objects;
     bool incremental_marking_stopped;
     bool can_start_incremental_marking;
+    bool sweeping_in_progress;
   };

   GCIdleTimeHandler()
       : mark_compacts_since_idle_round_started_(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);

   void NotifyIdleMarkCompact() {
=======================================
--- /branches/bleeding_edge/src/heap/heap.cc    Fri Aug 22 11:36:23 2014 UTC
+++ /branches/bleeding_edge/src/heap/heap.cc    Fri Aug 22 12:32:12 2014 UTC
@@ -4296,6 +4296,8 @@
heap_state.incremental_marking_stopped = incremental_marking()->IsStopped();
   // TODO(ulan): Start incremental marking only for large heaps.
   heap_state.can_start_incremental_marking = true;
+  heap_state.sweeping_in_progress =
+      mark_compact_collector()->sweeping_in_progress();

   GCIdleTimeAction action =
       gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state, tracer());
@@ -4321,18 +4323,13 @@
     case DO_SCAVENGE:
       CollectGarbage(NEW_SPACE, "idle notification: scavenge");
       break;
+    case DO_FINALIZE_SWEEPING:
+      mark_compact_collector()->EnsureSweepingCompleted();
+      break;
     case DO_NOTHING:
       result = true;
       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;
 }

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to