Bug 1422575 - Give store buffer hash sets a minimum capacity to reduce the chance of OOM while adding entries r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Thu, 07 Dec 2017 18:29:33 +0000
changeset 395640 1938afc341937d701acfb196279193f4cc640696
parent 395639 115d70e6c818c34624e7b9a0a2a1579ad92f1b40
child 395641 c35ad676551a69dba04514ee7d00e98a6332b367
push id33049
push usercsabou@mozilla.com
push dateFri, 08 Dec 2017 09:57:17 +0000
treeherdermozilla-central@437bfd403b76 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1422575
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1422575 - Give store buffer hash sets a minimum capacity to reduce the chance of OOM while adding entries r=sfink
js/src/gc/StoreBuffer.h
--- a/js/src/gc/StoreBuffer.h
+++ b/js/src/gc/StoreBuffer.h
@@ -72,33 +72,40 @@ class StoreBuffer
         StoreSet stores_;
 
         /*
          * A one element cache in front of the canonical set to speed up
          * temporary instances of HeapPtr.
          */
         T last_;
 
-        /* Maximum number of entries before we request a minor GC. */
-        const static size_t MaxEntries = 48 * 1024 / sizeof(T);
+        /*
+         * Maximum number of entries before we request a minor GC.
+         *
+         * This is passed to HashSet::init(), which will pre-allocate a hash
+         * table capable of holding this many entries before rehashing, which is
+         * currently 4/3 this value.
+         */
+        const static size_t MaxEntries = 8192;
 
         explicit MonoTypeBuffer() : last_(T()) {}
         ~MonoTypeBuffer() { stores_.finish(); }
 
         MOZ_MUST_USE bool init() {
-            if (!stores_.initialized() && !stores_.init())
+            if (!stores_.initialized() && !stores_.init(MaxEntries))
                 return false;
             clear();
             return true;
         }
 
         void clear() {
             last_ = T();
             if (stores_.initialized())
                 stores_.clear();
+            MOZ_ASSERT(stores_.capacity() > MaxEntries);
         }
 
         /* Add one item to the buffer. */
         void put(StoreBuffer* owner, const T& t) {
             MOZ_ASSERT(stores_.initialized());
             sinkStore(owner);
             last_ = t;
         }