Title: [232210] trunk
Revision
232210
Author
[email protected]
Date
2018-05-25 15:47:59 -0700 (Fri, 25 May 2018)

Log Message

Make JSC have a mini mode that kicks in when the JIT is disabled
https://bugs.webkit.org/show_bug.cgi?id=185931

Reviewed by Mark Lam.

Source/_javascript_Core:

This patch makes JSC have a mini VM mode. This currently only kicks in
when the process can't JIT. Mini VM now means a few things:
- We always use a 1.27x heap growth factor. This number was the best tradeoff
  between memory use progression and time regression in run-testmem. We may
  want to tune this more in the future as we make other mini VM changes.
- We always sweep synchronously.
- We disable generational GC.
        
I'm going to continue to extend what mini VM mode means in future changes.
        
This patch is a 50% memory progression and an ~8-9% time regression
on run-testmem when running in mini VM mode with the JIT disabled.

* heap/Heap.cpp:
(JSC::Heap::collectNow):
(JSC::Heap::finalize):
(JSC::Heap::useGenerationalGC):
(JSC::Heap::shouldSweepSynchronously):
(JSC::Heap::shouldDoFullCollection):
* heap/Heap.h:
* runtime/Options.h:
* runtime/VM.cpp:
(JSC::VM::isInMiniMode):
* runtime/VM.h:

Tools:

This renames a variable for clarity.

* Scripts/run-testmem:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (232209 => 232210)


--- trunk/Source/_javascript_Core/ChangeLog	2018-05-25 21:53:17 UTC (rev 232209)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-05-25 22:47:59 UTC (rev 232210)
@@ -1,5 +1,37 @@
 2018-05-25  Saam Barati  <[email protected]>
 
+        Make JSC have a mini mode that kicks in when the JIT is disabled
+        https://bugs.webkit.org/show_bug.cgi?id=185931
+
+        Reviewed by Mark Lam.
+
+        This patch makes JSC have a mini VM mode. This currently only kicks in
+        when the process can't JIT. Mini VM now means a few things:
+        - We always use a 1.27x heap growth factor. This number was the best tradeoff
+          between memory use progression and time regression in run-testmem. We may
+          want to tune this more in the future as we make other mini VM changes.
+        - We always sweep synchronously.
+        - We disable generational GC.
+        
+        I'm going to continue to extend what mini VM mode means in future changes.
+        
+        This patch is a 50% memory progression and an ~8-9% time regression
+        on run-testmem when running in mini VM mode with the JIT disabled.
+
+        * heap/Heap.cpp:
+        (JSC::Heap::collectNow):
+        (JSC::Heap::finalize):
+        (JSC::Heap::useGenerationalGC):
+        (JSC::Heap::shouldSweepSynchronously):
+        (JSC::Heap::shouldDoFullCollection):
+        * heap/Heap.h:
+        * runtime/Options.h:
+        * runtime/VM.cpp:
+        (JSC::VM::isInMiniMode):
+        * runtime/VM.h:
+
+2018-05-25  Saam Barati  <[email protected]>
+
         Have a memory test where we can validate JSCs mini memory mode
         https://bugs.webkit.org/show_bug.cgi?id=185932
 

Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (232209 => 232210)


--- trunk/Source/_javascript_Core/heap/Heap.cpp	2018-05-25 21:53:17 UTC (rev 232209)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp	2018-05-25 22:47:59 UTC (rev 232210)
@@ -127,6 +127,9 @@
 
 size_t proportionalHeapSize(size_t heapSize, size_t ramSize)
 {
+    if (VM::isInMiniMode())
+        return Options::miniVMHeapGrowthFactor() * heapSize;
+
 #if PLATFORM(IOS)
     size_t memoryFootprint = bmalloc::api::memoryFootprint();
     if (memoryFootprint < ramSize * Options::smallHeapRAMFraction())
@@ -1049,7 +1052,7 @@
         if (UNLIKELY(Options::useImmortalObjects()))
             sweeper().stopSweeping();
         
-        bool alreadySweptInCollectSync = Options::sweepSynchronously();
+        bool alreadySweptInCollectSync = shouldSweepSynchronously();
         if (!alreadySweptInCollectSync) {
             if (Options::logGC())
                 dataLog("[GC<", RawPointer(this), ">: ");
@@ -2043,7 +2046,7 @@
     for (const HeapFinalizerCallback& callback : m_heapFinalizerCallbacks)
         callback.run(*vm());
     
-    if (Options::sweepSynchronously())
+    if (shouldSweepSynchronously())
         sweepSynchronously();
 
     if (Options::logGC()) {
@@ -2396,9 +2399,19 @@
     collectNow(synchronousness, CollectionScope::Full);
 }
 
+bool Heap::useGenerationalGC()
+{
+    return Options::useGenerationalGC() && !VM::isInMiniMode();
+}
+
+bool Heap::shouldSweepSynchronously()
+{
+    return Options::sweepSynchronously() || VM::isInMiniMode();
+}
+
 bool Heap::shouldDoFullCollection()
 {
-    if (!Options::useGenerationalGC())
+    if (!useGenerationalGC())
         return true;
 
     if (!m_currentRequest.scope)

Modified: trunk/Source/_javascript_Core/heap/Heap.h (232209 => 232210)


--- trunk/Source/_javascript_Core/heap/Heap.h	2018-05-25 21:53:17 UTC (rev 232209)
+++ trunk/Source/_javascript_Core/heap/Heap.h	2018-05-25 22:47:59 UTC (rev 232210)
@@ -556,6 +556,9 @@
     void assertMarkStacksEmpty();
 
     void setBonusVisitorTask(RefPtr<SharedTask<void(SlotVisitor&)>>);
+
+    static bool useGenerationalGC();
+    static bool shouldSweepSynchronously();
     
     const HeapType m_heapType;
     const size_t m_ramSize;

Modified: trunk/Source/_javascript_Core/runtime/Options.h (232209 => 232210)


--- trunk/Source/_javascript_Core/runtime/Options.h	2018-05-25 21:53:17 UTC (rev 232209)
+++ trunk/Source/_javascript_Core/runtime/Options.h	2018-05-25 22:47:59 UTC (rev 232210)
@@ -237,6 +237,7 @@
     v(double, mediumHeapRAMFraction, 0.5, Normal, nullptr) \
     v(double, mediumHeapGrowthFactor, 1.5, Normal, nullptr) \
     v(double, largeHeapGrowthFactor, 1.24, Normal, nullptr) \
+    v(double, miniVMHeapGrowthFactor, 1.27, Normal, nullptr) \
     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) \
@@ -509,8 +510,9 @@
     v(bool, useBigInt, false, Normal, "If true, we will enable BigInt support.") \
     v(bool, useIntlNumberFormatToParts, enableIntlNumberFormatToParts, Normal, "If true, we will enable Intl.NumberFormat.prototype.formatToParts") \
     v(bool, useIntlPluralRules, enableIntlPluralRules, Normal, "If true, we will enable Intl.PluralRules.") \
-    v(bool, useArrayAllocationProfiling, true, Normal, "If true, we will use our normal array allocation profiling. If false, the allocation profile will always claim to be undecided.")\
-    v(bool, forcePolyProto, false, Normal, "If true, create_this will always create an object with a poly proto structure.")
+    v(bool, useArrayAllocationProfiling, true, Normal, "If true, we will use our normal array allocation profiling. If false, the allocation profile will always claim to be undecided.") \
+    v(bool, forcePolyProto, false, Normal, "If true, create_this will always create an object with a poly proto structure.") \
+    v(bool, forceMiniVMMode, false, Normal, "If true, it will force mini VM mode on.")
 
 
 enum OptionEquivalence {

Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (232209 => 232210)


--- trunk/Source/_javascript_Core/runtime/VM.cpp	2018-05-25 21:53:17 UTC (rev 232209)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp	2018-05-25 22:47:59 UTC (rev 232210)
@@ -238,6 +238,11 @@
 #endif
 }
 
+bool VM::isInMiniMode()
+{
+    return !canUseJIT() || Options::forceMiniVMMode();
+}
+
 VM::VM(VMType vmType, HeapType heapType)
     : m_apiLock(adoptRef(new JSLock(this)))
 #if USE(CF)

Modified: trunk/Source/_javascript_Core/runtime/VM.h (232209 => 232210)


--- trunk/Source/_javascript_Core/runtime/VM.h	2018-05-25 21:53:17 UTC (rev 232209)
+++ trunk/Source/_javascript_Core/runtime/VM.h	2018-05-25 22:47:59 UTC (rev 232210)
@@ -558,6 +558,7 @@
     static JS_EXPORT_PRIVATE bool canUseAssembler();
     static JS_EXPORT_PRIVATE bool canUseJIT();
     static JS_EXPORT_PRIVATE bool canUseRegExpJIT();
+    static JS_EXPORT_PRIVATE bool isInMiniMode();
 
     SourceProviderCache* addSourceProviderCache(SourceProvider*);
     void clearSourceProviderCaches();

Modified: trunk/Tools/ChangeLog (232209 => 232210)


--- trunk/Tools/ChangeLog	2018-05-25 21:53:17 UTC (rev 232209)
+++ trunk/Tools/ChangeLog	2018-05-25 22:47:59 UTC (rev 232210)
@@ -1,3 +1,14 @@
+2018-05-25  Saam Barati  <[email protected]>
+
+        Make JSC have a mini mode that kicks in when the JIT is disabled
+        https://bugs.webkit.org/show_bug.cgi?id=185931
+
+        Reviewed by Mark Lam.
+
+        This renames a variable for clarity.
+
+        * Scripts/run-testmem:
+
 2018-05-25  Alex Christensen  <[email protected]>
 
         URL::host should return a StringView to reduce allocations

Modified: trunk/Tools/Scripts/run-testmem (232209 => 232210)


--- trunk/Tools/Scripts/run-testmem	2018-05-25 21:53:17 UTC (rev 232209)
+++ trunk/Tools/Scripts/run-testmem	2018-05-25 22:47:59 UTC (rev 232210)
@@ -121,14 +121,14 @@
     files.sort_by { | (path) | File.basename(path) }
 end
 
-def geomean(x)
-    score = x.inject(1.0, :*)
-    score ** (1.0 / x.length)
+def geomean(arr)
+    score = arr.inject(1.0, :*)
+    score ** (1.0 / arr.length)
 end
 
-def mean(x)
-    sum = x.inject(0.0, :+)
-    sum / x.length
+def mean(arr)
+    sum = arr.inject(0.0, :+)
+    sum / arr.length
 end
 
 def runTest(path, iters)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to