[GC] Change behavior when reaching external allocation limit
authormlippautz <mlippautz@chromium.org>
Wed, 5 Aug 2015 13:29:01 +0000 (06:29 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 5 Aug 2015 13:29:51 +0000 (13:29 +0000)
With the recent changes to the incremental marking API we can now kick off
incremental marking while respecting callback flags.

Performance neutral for smoothness.image_decoding_cases on N9 (read: does not
crash) as long as we synchronously process phantom callbacks
(kGCCallbackFlagForced).

OORT single run:
  "marksweep": {
    "count": 5,
    "pause_min": 7.5,
    "pause_max": 158.8,
    "pause_avg": 97.52000000000001,
    "pause_gt_10ms": 4
  }
  --- vs ---
  "marksweep": {
    "count": 5,
    "pause_min": 16.2,
    "pause_max": 22.1,
    "pause_avg": 19.32,
    "pause_gt_10ms": 5
  }

The number of actual full GCs varies. The improvement manifests in reduced
maximum and average pauses.

BUG=chromium:515795
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#30028}

src/api.cc
src/flag-definitions.h

index 2b874ac..fea9f9e 100644 (file)
@@ -6884,8 +6884,20 @@ Local<Integer> v8::Integer::NewFromUnsigned(Isolate* isolate, uint32_t value) {
 
 
 void Isolate::CollectAllGarbage(const char* gc_reason) {
-  reinterpret_cast<i::Isolate*>(this)->heap()->CollectAllGarbage(
-      i::Heap::kNoGCFlags, gc_reason, v8::kGCCallbackFlagForced);
+  i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap();
+  if (heap->incremental_marking()->IsStopped()) {
+    heap->StartIncrementalMarking(i::Heap::kNoGCFlags, kGCCallbackFlagForced,
+                                  gc_reason);
+  }
+  // TODO(mlippautz): Compute the time slice for incremental marking based on
+  // memory pressure.
+  double deadline = heap->MonotonicallyIncreasingTimeInMs() +
+                    i::FLAG_external_allocation_limit_incremental_time;
+  heap->AdvanceIncrementalMarking(0, deadline,
+                                  i::IncrementalMarking::StepActions(
+                                      i::IncrementalMarking::GC_VIA_STACK_GUARD,
+                                      i::IncrementalMarking::FORCE_MARKING,
+                                      i::IncrementalMarking::FORCE_COMPLETION));
 }
 
 
index 60bbdc7..5013215 100644 (file)
@@ -810,6 +810,10 @@ DEFINE_BOOL(manual_evacuation_candidates_selection, false,
             "Test mode only flag. It allows an unit test to select evacuation "
             "candidates pages (requires --stress_compaction).")
 
+// api.cc
+DEFINE_INT(external_allocation_limit_incremental_time, 1,
+           "Time spent in incremental marking steps (in ms) once the external "
+           "allocation limit is reached")
 
 //
 // Dev shell flags