Title: [145171] trunk/Source/_javascript_Core
Revision
145171
Author
[email protected]
Date
2013-03-07 19:01:27 -0800 (Thu, 07 Mar 2013)

Log Message

REGRESSION (r143759): 40% JSBench regression, 20% Octane/closure regression, 40% Octane/jquery regression, 2% Octane regression
https://bugs.webkit.org/show_bug.cgi?id=111797

Reviewed by Oliver Hunt.

The bot's testing configuration stresses the cache's starting guess
of 1MB.

This patch removes any starting guess, and just uses wall clock time
to discover the initial working set size of an app, in code size.

* runtime/CodeCache.cpp:
(JSC::CodeCacheMap::pruneSlowCase): Update our timer as we go.

Also fixed a bug where pruning from 0 to 0 would hang -- that case is
a possibility now that we start with a capacity of 0.

* runtime/CodeCache.h:
(CodeCacheMap):
(JSC::CodeCacheMap::CodeCacheMap):
(JSC::CodeCacheMap::add):
(JSC::CodeCacheMap::prune): Don't prune if we're in the middle of
discovering the working set size of an app, in code size.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (145170 => 145171)


--- trunk/Source/_javascript_Core/ChangeLog	2013-03-08 02:29:48 UTC (rev 145170)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-03-08 03:01:27 UTC (rev 145171)
@@ -1,3 +1,29 @@
+2013-03-07  Geoffrey Garen  <[email protected]>
+
+        REGRESSION (r143759): 40% JSBench regression, 20% Octane/closure regression, 40% Octane/jquery regression, 2% Octane regression
+        https://bugs.webkit.org/show_bug.cgi?id=111797
+
+        Reviewed by Oliver Hunt.
+
+        The bot's testing configuration stresses the cache's starting guess
+        of 1MB.
+
+        This patch removes any starting guess, and just uses wall clock time
+        to discover the initial working set size of an app, in code size.
+
+        * runtime/CodeCache.cpp:
+        (JSC::CodeCacheMap::pruneSlowCase): Update our timer as we go.
+
+        Also fixed a bug where pruning from 0 to 0 would hang -- that case is
+        a possibility now that we start with a capacity of 0.
+
+        * runtime/CodeCache.h:
+        (CodeCacheMap):
+        (JSC::CodeCacheMap::CodeCacheMap):
+        (JSC::CodeCacheMap::add):
+        (JSC::CodeCacheMap::prune): Don't prune if we're in the middle of
+        discovering the working set size of an app, in code size.
+
 2013-03-07  Michael Saboff  <[email protected]>
 
         Crash when updating predictions below JSC::arrayProtoFuncForEach on tuaw.com article

Modified: trunk/Source/_javascript_Core/runtime/CodeCache.cpp (145170 => 145171)


--- trunk/Source/_javascript_Core/runtime/CodeCache.cpp	2013-03-08 02:29:48 UTC (rev 145170)
+++ trunk/Source/_javascript_Core/runtime/CodeCache.cpp	2013-03-08 03:01:27 UTC (rev 145171)
@@ -36,9 +36,18 @@
 
 namespace JSC {
 
+const double CodeCacheMap::workingSetTime = 10.0;
+
 void CodeCacheMap::pruneSlowCase()
 {
-    while (m_size >= m_capacity) {
+    m_minCapacity = m_size - m_sizeAtLastPrune;
+    m_sizeAtLastPrune = m_size;
+    m_timeAtLastPrune = monotonicallyIncreasingTime();
+
+    if (m_capacity < m_minCapacity)
+        m_capacity = m_minCapacity;
+
+    while (m_size > m_capacity) {
         MapType::iterator it = m_map.begin();
         m_size -= it->key.length();
         m_map.remove(it);

Modified: trunk/Source/_javascript_Core/runtime/CodeCache.h (145170 => 145171)


--- trunk/Source/_javascript_Core/runtime/CodeCache.h	2013-03-08 02:29:48 UTC (rev 145170)
+++ trunk/Source/_javascript_Core/runtime/CodeCache.h	2013-03-08 03:01:27 UTC (rev 145171)
@@ -31,6 +31,7 @@
 #include "SourceCode.h"
 #include "Strong.h"
 #include "WeakRandom.h"
+#include <wtf/CurrentTime.h>
 #include <wtf/FixedArray.h>
 #include <wtf/Forward.h>
 #include <wtf/PassOwnPtr.h>
@@ -135,16 +136,16 @@
     typedef MapType::iterator iterator;
     typedef MapType::AddResult AddResult;
 
-    enum { MinCacheCapacity = 1000000 }; // Size in characters
-
     CodeCacheMap()
         : m_size(0)
-        , m_capacity(MinCacheCapacity)
+        , m_sizeAtLastPrune(0)
+        , m_timeAtLastPrune(monotonicallyIncreasingTime())
+        , m_minCapacity(0)
+        , m_capacity(0)
         , m_age(0)
     {
     }
 
-
     AddResult add(const SourceCodeKey& key, const SourceCodeValue& value)
     {
         prune();
@@ -167,8 +168,8 @@
             // infer that requested objects are subject to low eviction probability,
             // so we shrink the cache to save memory.
             m_capacity -= recencyBias * key.length();
-            if (m_capacity < MinCacheCapacity)
-                m_capacity = MinCacheCapacity;
+            if (m_capacity < m_minCapacity)
+                m_capacity = m_minCapacity;
         }
 
         addResult.iterator->value.age = m_age;
@@ -192,6 +193,11 @@
     int64_t age() { return m_age; }
 
 private:
+    // This constant factor biases cache capacity toward allowing a minimum
+    // working set to enter the cache before it starts evicting.
+    static const double workingSetTime;
+    static const int64_t workingSetMax = 16000000;
+
     // This constant factor biases cache capacity toward recent activity. We
     // want to adapt to changing workloads.
     static const int64_t recencyBias = 4;
@@ -204,13 +210,21 @@
     void pruneSlowCase();
     void prune()
     {
-        if (m_size < m_capacity)
+        if (m_size <= m_capacity)
             return;
+
+        if (monotonicallyIncreasingTime() - m_timeAtLastPrune < workingSetTime
+            && m_size - m_sizeAtLastPrune < workingSetMax)
+                return;
+
         pruneSlowCase();
     }
 
     MapType m_map;
     int64_t m_size;
+    int64_t m_sizeAtLastPrune;
+    double m_timeAtLastPrune;
+    int64_t m_minCapacity;
     int64_t m_capacity;
     int64_t m_age;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to