Title: [209825] trunk/Source/_javascript_Core
Revision
209825
Author
[email protected]
Date
2016-12-14 12:57:20 -0800 (Wed, 14 Dec 2016)

Log Message

Devices with fewer cores should use a more aggressive GC schedule by default
https://bugs.webkit.org/show_bug.cgi?id=165859

Reviewed by Mark Lam.

* heap/Heap.cpp:
(JSC::Heap::markToFixpoint): Log when we have an unexpected delay in wake-up.
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::drainInParallelPassively): Don't drain passively if there aren't many cores.
* runtime/Options.cpp:
(JSC::overrideDefaults): Change the heuristics if we have fewer cores.
(JSC::Options::initialize):
* runtime/Options.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (209824 => 209825)


--- trunk/Source/_javascript_Core/ChangeLog	2016-12-14 20:56:50 UTC (rev 209824)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-12-14 20:57:20 UTC (rev 209825)
@@ -1,3 +1,19 @@
+2016-12-14  Filip Pizlo  <[email protected]>
+
+        Devices with fewer cores should use a more aggressive GC schedule by default
+        https://bugs.webkit.org/show_bug.cgi?id=165859
+
+        Reviewed by Mark Lam.
+
+        * heap/Heap.cpp:
+        (JSC::Heap::markToFixpoint): Log when we have an unexpected delay in wake-up.
+        * heap/SlotVisitor.cpp:
+        (JSC::SlotVisitor::drainInParallelPassively): Don't drain passively if there aren't many cores.
+        * runtime/Options.cpp:
+        (JSC::overrideDefaults): Change the heuristics if we have fewer cores.
+        (JSC::Options::initialize):
+        * runtime/Options.h:
+
 2016-12-14  Mark Lam  <[email protected]>
 
         BytecodeBasicBlock::computeImpl() should not keep iterating blocks if all jump targets have already been found.

Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (209824 => 209825)


--- trunk/Source/_javascript_Core/heap/Heap.cpp	2016-12-14 20:56:50 UTC (rev 209824)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp	2016-12-14 20:57:20 UTC (rev 209825)
@@ -661,17 +661,24 @@
                 do {
                     auto decision = scheduler.currentDecision();
                     if (decision.shouldBeResumed()) {
-                        ResumeTheWorldScope resumeTheWorldScope(*this);
-                        drainResult = m_collectorSlotVisitor->drainInParallelPassively(decision.timeToStop());
-                        if (drainResult == SlotVisitor::SharedDrainResult::Done) {
-                            // At this point we will stop. But maybe the scheduler does not want
-                            // that.
-                            Seconds scheduledIdle = decision.timeToStop() - MonotonicTime::now();
-                            // It's totally unclear what the value of collectPermittedIdleRatio
-                            // should be, other than it should be greater than 0. You could even
-                            // argue for it being greater than 1. We should tune it.
-                            sleep(scheduledIdle * Options::collectorPermittedIdleRatio());
+                        {
+                            ResumeTheWorldScope resumeTheWorldScope(*this);
+                            drainResult = m_collectorSlotVisitor->drainInParallelPassively(decision.timeToStop());
+                            if (drainResult == SlotVisitor::SharedDrainResult::Done) {
+                                // At this point we will stop. But maybe the scheduler does not want
+                                // that.
+                                Seconds scheduledIdle = decision.timeToStop() - MonotonicTime::now();
+                                // It's totally unclear what the value of collectPermittedIdleRatio
+                                // should be, other than it should be greater than 0. You could even
+                                // argue for it being greater than 1. We should tune it.
+                                sleep(scheduledIdle * Options::collectorPermittedIdleRatio());
+                            }
                         }
+                        if (Options::logGC()) {
+                            Seconds wakeUpLatency = MonotonicTime::now() - decision.timeToStop();
+                            if (wakeUpLatency >= 1_ms)
+                                dataLog("wul!=", wakeUpLatency.milliseconds(), " ms ");
+                        }
                     } else
                         drainResult = m_collectorSlotVisitor->drainInParallel(decision.timeToResume());
                 } while (drainResult != SlotVisitor::SharedDrainResult::Done);

Modified: trunk/Source/_javascript_Core/heap/SlotVisitor.cpp (209824 => 209825)


--- trunk/Source/_javascript_Core/heap/SlotVisitor.cpp	2016-12-14 20:56:50 UTC (rev 209824)
+++ trunk/Source/_javascript_Core/heap/SlotVisitor.cpp	2016-12-14 20:57:20 UTC (rev 209825)
@@ -572,13 +572,19 @@
     
     ASSERT(Options::numberOfGCMarkers());
     
-    if (!m_heap.hasHeapAccess() || m_heap.collectorBelievesThatTheWorldIsStopped()) {
+    if (Options::numberOfGCMarkers() < 4
+        || !m_heap.hasHeapAccess()
+        || m_heap.collectorBelievesThatTheWorldIsStopped()) {
         // This is an optimization over drainInParallel() when we have a concurrent mutator but
         // otherwise it is not profitable.
         return drainInParallel(timeout);
     }
+
+    LockHolder locker(m_heap.m_markingMutex);
+    m_collectorStack.transferTo(*m_heap.m_sharedCollectorMarkStack);
+    m_mutatorStack.transferTo(*m_heap.m_sharedMutatorMarkStack);
+    m_heap.m_markingConditionVariable.notifyAll();
     
-    LockHolder locker(m_heap.m_markingMutex);
     for (;;) {
         if (hasElapsed(timeout))
             return SharedDrainResult::TimedOut;

Modified: trunk/Source/_javascript_Core/runtime/Options.cpp (209824 => 209825)


--- trunk/Source/_javascript_Core/runtime/Options.cpp	2016-12-14 20:56:50 UTC (rev 209824)
+++ trunk/Source/_javascript_Core/runtime/Options.cpp	2016-12-14 20:57:20 UTC (rev 209825)
@@ -306,6 +306,15 @@
     }
 }
 
+static void overrideDefaults()
+{
+    if (WTF::numberOfProcessorCores() < 4) {
+        Options::maximumMutatorUtilization() = 0.6;
+        Options::concurrentGCMaxHeadroom() = 1.4;
+        Options::concurrentGCPeriodMS() = 10;
+    }
+}
+
 static void recomputeDependentOptions()
 {
 #if !defined(NDEBUG)
@@ -435,6 +444,8 @@
             name_##Default() = defaultValue_;
             JSC_OPTIONS(FOR_EACH_OPTION)
 #undef FOR_EACH_OPTION
+
+            overrideDefaults();
                 
             // Allow environment vars to override options if applicable.
             // The evn var should be the name of the option prefixed with
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to