Title: [230360] trunk/Source
Revision
230360
Author
sbar...@apple.com
Date
2018-04-06 17:00:34 -0700 (Fri, 06 Apr 2018)

Log Message

Source/bmalloc:
bmalloc virtual allocation API should not treat memory it vends as dirty with respect to how it drives the scavenger
https://bugs.webkit.org/show_bug.cgi?id=184342

Reviewed by Mark Lam.

Currently, the only user of this API is Wasm. Ideally, Wasm would tell
us exactly which page is dirtied. We should really do that at some point:
https://bugs.webkit.org/show_bug.cgi?id=184207

However, until we do that, it's better to treat none of the virtual memory
we vend as dirty, versus what we do now, which is treat it all as dirty.
This dirty memory tracking helps drive the scavenger, so on iOS, having the
scavenger think its under memory pressure because of memory it can't free isn't
useful.

* bmalloc/bmalloc.cpp:
(bmalloc::api::tryLargeZeroedMemalignVirtual):
(bmalloc::api::freeLargeVirtual):
* bmalloc/bmalloc.h:

Source/WTF:
bmalloc's tryLargeZeroedMemalignVirtual shouldn't treat the entire virtual size as dirty towards its footprint
https://bugs.webkit.org/show_bug.cgi?id=184207

Reviewed by Mark Lam.

* wtf/Gigacage.cpp:
(Gigacage::freeVirtualPages):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (230359 => 230360)


--- trunk/Source/WTF/ChangeLog	2018-04-06 23:53:30 UTC (rev 230359)
+++ trunk/Source/WTF/ChangeLog	2018-04-07 00:00:34 UTC (rev 230360)
@@ -1,3 +1,13 @@
+2018-04-06  Saam Barati  <sbar...@apple.com>
+
+        bmalloc's tryLargeZeroedMemalignVirtual shouldn't treat the entire virtual size as dirty towards its footprint
+        https://bugs.webkit.org/show_bug.cgi?id=184207
+
+        Reviewed by Mark Lam.
+
+        * wtf/Gigacage.cpp:
+        (Gigacage::freeVirtualPages):
+
 2018-04-05  Yusuke Suzuki  <utatane....@gmail.com>
 
         [WTF] Remove StaticLock

Modified: trunk/Source/WTF/wtf/Gigacage.cpp (230359 => 230360)


--- trunk/Source/WTF/wtf/Gigacage.cpp	2018-04-06 23:53:30 UTC (rev 230359)
+++ trunk/Source/WTF/wtf/Gigacage.cpp	2018-04-07 00:00:34 UTC (rev 230360)
@@ -108,12 +108,12 @@
     return result;
 }
 
-void freeVirtualPages(Kind kind, void* basePtr, size_t)
+void freeVirtualPages(Kind kind, void* basePtr, size_t size)
 {
     if (!basePtr)
         return;
     RELEASE_ASSERT(isCaged(kind, basePtr));
-    bmalloc::api::freeLargeVirtual(basePtr, bmalloc::heapKind(kind));
+    bmalloc::api::freeLargeVirtual(basePtr, size, bmalloc::heapKind(kind));
     WTF::compilerFence();
 }
 

Modified: trunk/Source/bmalloc/ChangeLog (230359 => 230360)


--- trunk/Source/bmalloc/ChangeLog	2018-04-06 23:53:30 UTC (rev 230359)
+++ trunk/Source/bmalloc/ChangeLog	2018-04-07 00:00:34 UTC (rev 230360)
@@ -1,3 +1,25 @@
+2018-04-06  Saam Barati  <sbar...@apple.com>
+
+        bmalloc virtual allocation API should not treat memory it vends as dirty with respect to how it drives the scavenger
+        https://bugs.webkit.org/show_bug.cgi?id=184342
+
+        Reviewed by Mark Lam.
+
+        Currently, the only user of this API is Wasm. Ideally, Wasm would tell
+        us exactly which page is dirtied. We should really do that at some point:
+        https://bugs.webkit.org/show_bug.cgi?id=184207
+        
+        However, until we do that, it's better to treat none of the virtual memory
+        we vend as dirty, versus what we do now, which is treat it all as dirty.
+        This dirty memory tracking helps drive the scavenger, so on iOS, having the
+        scavenger think its under memory pressure because of memory it can't free isn't
+        useful.
+
+        * bmalloc/bmalloc.cpp:
+        (bmalloc::api::tryLargeZeroedMemalignVirtual):
+        (bmalloc::api::freeLargeVirtual):
+        * bmalloc/bmalloc.h:
+
 2018-04-05  Saam Barati  <sbar...@apple.com>
 
         IsoHeapImpl not IsoHeapImplBase should add itself to AllIsoHeaps

Modified: trunk/Source/bmalloc/bmalloc/bmalloc.cpp (230359 => 230360)


--- trunk/Source/bmalloc/bmalloc/bmalloc.cpp	2018-04-06 23:53:30 UTC (rev 230359)
+++ trunk/Source/bmalloc/bmalloc/bmalloc.cpp	2018-04-07 00:00:34 UTC (rev 230360)
@@ -54,6 +54,13 @@
     {
         std::lock_guard<Mutex> lock(Heap::mutex());
         result = heap.tryAllocateLarge(lock, alignment, size);
+        if (result) {
+            // Don't track this as dirty memory that dictates how we drive the scavenger.
+            // FIXME: We should make it so that users of this API inform bmalloc which
+            // pages they dirty:
+            // https://bugs.webkit.org/show_bug.cgi?id=184207
+            heap.externalDecommit(lock, result, size);
+        }
     }
 
     if (result)
@@ -61,11 +68,13 @@
     return result;
 }
 
-void freeLargeVirtual(void* object, HeapKind kind)
+void freeLargeVirtual(void* object, size_t size, HeapKind kind)
 {
     kind = mapToActiveHeapKind(kind);
     Heap& heap = PerProcess<PerHeapKind<Heap>>::get()->at(kind);
     std::lock_guard<Mutex> lock(Heap::mutex());
+    // Balance out the externalDecommit when we allocated the zeroed virtual memory.
+    heap.externalCommit(lock, object, size);
     heap.deallocateLarge(lock, object);
 }
 

Modified: trunk/Source/bmalloc/bmalloc/bmalloc.h (230359 => 230360)


--- trunk/Source/bmalloc/bmalloc/bmalloc.h	2018-04-06 23:53:30 UTC (rev 230359)
+++ trunk/Source/bmalloc/bmalloc/bmalloc.h	2018-04-07 00:00:34 UTC (rev 230360)
@@ -82,7 +82,7 @@
 
 BEXPORT void freeOutOfLine(void* object, HeapKind kind = HeapKind::Primary);
 
-BEXPORT void freeLargeVirtual(void* object, HeapKind kind = HeapKind::Primary);
+BEXPORT void freeLargeVirtual(void* object, size_t, HeapKind kind = HeapKind::Primary);
 
 inline void scavengeThisThread()
 {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to