Title: [220172] branches/safari-604-branch/Source/_javascript_Core

Diff

Modified: branches/safari-604-branch/Source/_javascript_Core/ChangeLog (220171 => 220172)


--- branches/safari-604-branch/Source/_javascript_Core/ChangeLog	2017-08-03 01:33:13 UTC (rev 220171)
+++ branches/safari-604-branch/Source/_javascript_Core/ChangeLog	2017-08-03 01:33:16 UTC (rev 220172)
@@ -1,3 +1,26 @@
+2017-08-02  Jason Marcell  <[email protected]>
+
+        Cherry-pick r220144. rdar://problem/33687404
+
+    2017-08-02  Saam Barati  <[email protected]>
+
+            On memory-constrained iOS devices, reduce the rate at which the JS heap grows before a GC to try to keep more memory available for the system
+            https://bugs.webkit.org/show_bug.cgi?id=175041
+            <rdar://problem/33659370>
+
+            Reviewed by Filip Pizlo.
+
+            The testing I have done shows that this new function is a ~10%
+            progression running JetStream on 1GB iOS devices. I've also tried
+            this on a few > 1GB iOS devices, and the testing shows this is either neutral
+            or a regression. Right now, we'll just enable this for <= 1GB devices
+            since it's a win. In the future, we might want to either look into
+            tweaking these parameters or coming up with a new function for > 1GB
+            devices.
+
+            * heap/Heap.cpp:
+            * runtime/Options.h:
+
 2017-07-31  Jason Marcell  <[email protected]>
 
         Cherry-pick r220012. rdar://problem/33619526

Modified: branches/safari-604-branch/Source/_javascript_Core/heap/Heap.cpp (220171 => 220172)


--- branches/safari-604-branch/Source/_javascript_Core/heap/Heap.cpp	2017-08-03 01:33:13 UTC (rev 220171)
+++ branches/safari-604-branch/Source/_javascript_Core/heap/Heap.cpp	2017-08-03 01:33:16 UTC (rev 220172)
@@ -71,6 +71,7 @@
 #include <algorithm>
 #if PLATFORM(IOS)
 #include <bmalloc/bmalloc.h>
+#include <sys/sysctl.h>
 #endif
 #include <wtf/CurrentTime.h>
 #include <wtf/ListDump.h>
@@ -115,9 +116,39 @@
     return Options::smallHeapSize();
 }
 
+#if PLATFORM(IOS)
+static bool useAggressiveGCTrigger()
+{
+    static bool useAggressiveGCTrigger;
+    static std::once_flag once;
+    std::call_once(once, [] {
+        useAggressiveGCTrigger = false;
+
+        if (Options::forceAggressiveGCTrigger()) {
+            useAggressiveGCTrigger = true;
+            return;
+        }
+
+        uint64_t memSizeInBytes;
+        size_t sizeofMemSize = sizeof(memSizeInBytes);
+        if (sysctlbyname("hw.memsize", &memSizeInBytes, &sizeofMemSize, nullptr, 0))
+            return;
+        useAggressiveGCTrigger = memSizeInBytes <= 1 * GB;
+    });
+
+    return useAggressiveGCTrigger;
+}
+#endif
+
 size_t proportionalHeapSize(size_t heapSize, size_t ramSize)
 {
 #if PLATFORM(IOS)
+    if (useAggressiveGCTrigger()) {
+        double memoryUsed = bmalloc::api::percentAvailableMemoryInUse();
+        double result = ((1 - memoryUsed) / Options::aggressiveGCTriggerScalingValue()) + 1;
+        return heapSize * std::max(std::min(result, Options::aggressiveGCTriggerMaxMultiplier()), Options::aggressiveGCTriggerMinMultiplier());
+    }
+
     size_t memoryFootprint = bmalloc::api::memoryFootprint();
     if (memoryFootprint < ramSize * Options::smallHeapRAMFraction())
         return Options::smallHeapGrowthFactor() * heapSize;

Modified: branches/safari-604-branch/Source/_javascript_Core/runtime/Options.h (220171 => 220172)


--- branches/safari-604-branch/Source/_javascript_Core/runtime/Options.h	2017-08-03 01:33:13 UTC (rev 220171)
+++ branches/safari-604-branch/Source/_javascript_Core/runtime/Options.h	2017-08-03 01:33:16 UTC (rev 220172)
@@ -210,6 +210,10 @@
     v(double, mediumHeapRAMFraction, 0.5, Normal, nullptr) \
     v(double, mediumHeapGrowthFactor, 1.5, Normal, nullptr) \
     v(double, largeHeapGrowthFactor, 1.24, Normal, nullptr) \
+    v(bool, forceAggressiveGCTrigger, false, Normal, "If true, on iOS, we will use a different formula for proportionalHeapSize().") \
+    v(double, aggressiveGCTriggerMinMultiplier, 1.07, Normal, "This is the minimum we must grow by for proportionalHeapSize() when doing aggressive triggering.") \
+    v(double, aggressiveGCTriggerMaxMultiplier, 2.0, Normal,  "This is the maximum we can grow by for proportionalHeapSize() when doing aggressive triggering.") \
+    v(double, aggressiveGCTriggerScalingValue, 3.5, Normal, "This scales the above formula. A larger number is more aggressive in limiting heap growth. A smaller number is more permissive in allowing heap growth.") \
     v(double, criticalGCMemoryThreshold, 0.80, Normal, "percent memory in use the GC considers critical.  The collector is much more aggressive above this threshold") \
     v(double, minimumMutatorUtilization, 0, Normal, nullptr) \
     v(double, maximumMutatorUtilization, 0.7, Normal, nullptr) \
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to