Bug 1398033 - Free dirty pages on memory pressure. r=njn
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 08 Sep 2017 14:50:42 +0900
changeset 429166 d212f4ad31669f227bba82022b04a5a0ec7859cc
parent 429165 404a3fe96ab028d5aea5a811388f1ffbb5701297
child 429167 28c89bcb7b70c21f29fddbf86628a49ad541deab
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1398033
milestone57.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 1398033 - Free dirty pages on memory pressure. r=njn Free dirty pages appear as "page-cache" in about:memory reports, but when minimizing memory, and more generally, on memory pressure, they're currently not force-free()ed on desktop, while they are on mobile. There doesn't seem to be much reason not to do it on desktop as well, and it should help reduce the noise in "explicit" allocations measurements on CI, too.
mobile/android/app/mobile.js
modules/libpref/init/all.js
xpcom/base/AvailableMemoryTracker.cpp
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -734,20 +734,16 @@ pref("media.plugins.enabled", true);
 //  0 = Let Stagefright choose hardware or software decoding (default)
 //  8 = Force software decoding
 // 16 = Force hardware decoding
 pref("media.stagefright.omxcodec.flags", 0);
 
 // Coalesce touch events to prevent them from flooding the event queue
 pref("dom.event.touch.coalescing.enabled", false);
 
-// On memory pressure, release dirty but unused pages held by jemalloc
-// back to the system.
-pref("memory.free_dirty_pages", true);
-
 pref("layout.framevisibility.numscrollportwidths", 1);
 pref("layout.framevisibility.numscrollportheights", 1);
 
 pref("layers.enable-tiles", true);
 
 // Enable the dynamic toolbar
 pref("browser.chrome.dynamictoolbar", true);
 
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -5201,18 +5201,19 @@ pref("memory.low_physical_memory_thresho
 pref("memory.low_memory_notification_interval_ms", 10000);
 #endif
 
 // How long must we wait before declaring that a window is a "ghost" (i.e., a
 // likely leak)?  This should be longer than it usually takes for an eligible
 // window to be collected via the GC/CC.
 pref("memory.ghost_window_timeout_seconds", 60);
 
-// Disable freeing dirty pages when minimizing memory.
-pref("memory.free_dirty_pages", false);
+// On memory pressure, release dirty but unused pages held by jemalloc
+// back to the system.
+pref("memory.free_dirty_pages", true);
 
 // Disable the Linux-specific, system-wide memory reporter.
 #ifdef XP_LINUX
 pref("memory.system_memory_reporter", false);
 #endif
 
 // Don't dump memory reports on OOM, by default.
 pref("memory.dump_reports_on_oom", false);
--- a/xpcom/base/AvailableMemoryTracker.cpp
+++ b/xpcom/base/AvailableMemoryTracker.cpp
@@ -328,34 +328,34 @@ public:
   void Init();
 
 private:
   static bool sFreeDirtyPages;
 };
 
 NS_IMPL_ISUPPORTS(nsMemoryPressureWatcher, nsIObserver)
 
-bool nsMemoryPressureWatcher::sFreeDirtyPages = false;
+bool nsMemoryPressureWatcher::sFreeDirtyPages = true;
 
 /**
  * Initialize and subscribe to the memory-pressure events. We subscribe to the
  * observer service in this method and not in the constructor because we need
  * to hold a strong reference to 'this' before calling the observer service.
  */
 void
 nsMemoryPressureWatcher::Init()
 {
   nsCOMPtr<nsIObserverService> os = services::GetObserverService();
 
   if (os) {
     os->AddObserver(this, "memory-pressure", /* ownsWeak */ false);
   }
 
   Preferences::AddBoolVarCache(&sFreeDirtyPages, "memory.free_dirty_pages",
-                               false);
+                               true);
 }
 
 /**
  * Reacts to all types of memory-pressure events, launches a runnable to
  * free dirty pages held by jemalloc.
  */
 NS_IMETHODIMP
 nsMemoryPressureWatcher::Observe(nsISupports* aSubject, const char* aTopic,