Bug 1414168 - Split the condition for the main arena_bin_run_size_calc loop into pieces. r=njn
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 07 Nov 2017 07:42:21 +0900
changeset 444160 5ab2a7bd031f3060cb57b072349fbc8e7178547a
parent 444159 7ae07e7920fec8d066b757acfc112746a2ab7c1c
child 444161 bd35bf43d67daa82877249cb9943dce3c6993c53
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1414168
milestone58.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 1414168 - Split the condition for the main arena_bin_run_size_calc loop into pieces. r=njn This is, practically speaking, a no-op, and will hopefully help make the following changes clearer.
memory/build/mozjemalloc.cpp
--- a/memory/build/mozjemalloc.cpp
+++ b/memory/build/mozjemalloc.cpp
@@ -2987,17 +2987,17 @@ arena_bin_run_size_calc(arena_bin_t* bin
     try_mask_nelms =
       (try_nregs >> (LOG2(sizeof(int)) + 3)) +
       ((try_nregs & ((1U << (LOG2(sizeof(int)) + 3)) - 1)) ? 1 : 0);
     try_reg0_offset = try_run_size - (try_nregs * bin->mSizeClass);
   } while (sizeof(arena_run_t) + (sizeof(unsigned) * (try_mask_nelms - 1)) >
            try_reg0_offset);
 
   // mRunSize expansion loop.
-  do {
+  while (true) {
     // Copy valid settings before trying more aggressive settings.
     good_run_size = try_run_size;
     good_nregs = try_nregs;
     good_mask_nelms = try_mask_nelms;
     good_reg0_offset = try_reg0_offset;
 
     // Try more aggressive settings.
     try_run_size += gPageSize;
@@ -3006,19 +3006,32 @@ arena_bin_run_size_calc(arena_bin_t* bin
     do {
       try_nregs--;
       try_mask_nelms =
         (try_nregs >> (LOG2(sizeof(int)) + 3)) +
         ((try_nregs & ((1U << (LOG2(sizeof(int)) + 3)) - 1)) ? 1 : 0);
       try_reg0_offset = try_run_size - (try_nregs * bin->mSizeClass);
     } while (sizeof(arena_run_t) + (sizeof(unsigned) * (try_mask_nelms - 1)) >
              try_reg0_offset);
-  } while (try_run_size <= gMaxLargeClass &&
-           RUN_MAX_OVRHD * (bin->mSizeClass << 3) > RUN_MAX_OVRHD_RELAX &&
-           (try_reg0_offset << RUN_BFP) > RUN_MAX_OVRHD * try_run_size);
+
+    // Don't allow runs larger than the largest possible large size class.
+    if (try_run_size > gMaxLargeClass) {
+      break;
+    }
+
+    // This doesn't match the comment above RUN_MAX_OVRHD_RELAX.
+    if (RUN_MAX_OVRHD * (bin->mSizeClass << 3) <= RUN_MAX_OVRHD_RELAX) {
+      break;
+    }
+
+    // Try to keep the run overhead below RUN_MAX_OVRHD.
+    if ((try_reg0_offset << RUN_BFP) <= RUN_MAX_OVRHD * try_run_size) {
+      break;
+    }
+  }
 
   MOZ_ASSERT(sizeof(arena_run_t) + (sizeof(unsigned) * (good_mask_nelms - 1)) <=
              good_reg0_offset);
   MOZ_ASSERT((good_mask_nelms << (LOG2(sizeof(int)) + 3)) >= good_nregs);
 
   // Copy final settings.
   bin->mRunSize = good_run_size;
   bin->mRunNumRegions = good_nregs;