Changeset 230360 in webkit


Ignore:
Timestamp:
Apr 6, 2018 5:00:34 PM (6 years ago)
Author:
sbarati@apple.com
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):

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r230303 r230360  
     12018-04-06  Saam Barati  <sbarati@apple.com>
     2
     3        bmalloc's tryLargeZeroedMemalignVirtual shouldn't treat the entire virtual size as dirty towards its footprint
     4        https://bugs.webkit.org/show_bug.cgi?id=184207
     5
     6        Reviewed by Mark Lam.
     7
     8        * wtf/Gigacage.cpp:
     9        (Gigacage::freeVirtualPages):
     10
    1112018-04-05  Yusuke Suzuki  <utatane.tea@gmail.com>
    212
  • trunk/Source/WTF/wtf/Gigacage.cpp

    r227951 r230360  
    109109}
    110110
    111 void freeVirtualPages(Kind kind, void* basePtr, size_t)
     111void freeVirtualPages(Kind kind, void* basePtr, size_t size)
    112112{
    113113    if (!basePtr)
    114114        return;
    115115    RELEASE_ASSERT(isCaged(kind, basePtr));
    116     bmalloc::api::freeLargeVirtual(basePtr, bmalloc::heapKind(kind));
     116    bmalloc::api::freeLargeVirtual(basePtr, size, bmalloc::heapKind(kind));
    117117    WTF::compilerFence();
    118118}
  • trunk/Source/bmalloc/ChangeLog

    r230317 r230360  
     12018-04-06  Saam Barati  <sbarati@apple.com>
     2
     3        bmalloc virtual allocation API should not treat memory it vends as dirty with respect to how it drives the scavenger
     4        https://bugs.webkit.org/show_bug.cgi?id=184342
     5
     6        Reviewed by Mark Lam.
     7
     8        Currently, the only user of this API is Wasm. Ideally, Wasm would tell
     9        us exactly which page is dirtied. We should really do that at some point:
     10        https://bugs.webkit.org/show_bug.cgi?id=184207
     11       
     12        However, until we do that, it's better to treat none of the virtual memory
     13        we vend as dirty, versus what we do now, which is treat it all as dirty.
     14        This dirty memory tracking helps drive the scavenger, so on iOS, having the
     15        scavenger think its under memory pressure because of memory it can't free isn't
     16        useful.
     17
     18        * bmalloc/bmalloc.cpp:
     19        (bmalloc::api::tryLargeZeroedMemalignVirtual):
     20        (bmalloc::api::freeLargeVirtual):
     21        * bmalloc/bmalloc.h:
     22
    1232018-04-05  Saam Barati  <sbarati@apple.com>
    224
  • trunk/Source/bmalloc/bmalloc/bmalloc.cpp

    r230308 r230360  
    5555        std::lock_guard<Mutex> lock(Heap::mutex());
    5656        result = heap.tryAllocateLarge(lock, alignment, size);
     57        if (result) {
     58            // Don't track this as dirty memory that dictates how we drive the scavenger.
     59            // FIXME: We should make it so that users of this API inform bmalloc which
     60            // pages they dirty:
     61            // https://bugs.webkit.org/show_bug.cgi?id=184207
     62            heap.externalDecommit(lock, result, size);
     63        }
    5764    }
    5865
     
    6269}
    6370
    64 void freeLargeVirtual(void* object, HeapKind kind)
     71void freeLargeVirtual(void* object, size_t size, HeapKind kind)
    6572{
    6673    kind = mapToActiveHeapKind(kind);
    6774    Heap& heap = PerProcess<PerHeapKind<Heap>>::get()->at(kind);
    6875    std::lock_guard<Mutex> lock(Heap::mutex());
     76    // Balance out the externalDecommit when we allocated the zeroed virtual memory.
     77    heap.externalCommit(lock, object, size);
    6978    heap.deallocateLarge(lock, object);
    7079}
  • trunk/Source/bmalloc/bmalloc/bmalloc.h

    r230308 r230360  
    8383BEXPORT void freeOutOfLine(void* object, HeapKind kind = HeapKind::Primary);
    8484
    85 BEXPORT void freeLargeVirtual(void* object, HeapKind kind = HeapKind::Primary);
     85BEXPORT void freeLargeVirtual(void* object, size_t, HeapKind kind = HeapKind::Primary);
    8686
    8787inline void scavengeThisThread()
Note: See TracChangeset for help on using the changeset viewer.