Changeset 194204 in webkit
- Timestamp:
- Dec 16, 2015 6:55:02 PM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r194183 r194204 1 2015-12-16 Andreas Kling <akling@apple.com> 2 3 Give kernel VM some hints about non-live memory-cached resources. 4 <https://webkit.org/b/152362> 5 6 Reviewed by Geoffrey Garen. 7 8 Add an API to OSAllocator for hinting to the OS that a range of memory 9 is not expected to be used anytime soon. 10 11 * wtf/OSAllocator.h: 12 * wtf/OSAllocatorPosix.cpp: 13 (WTF::OSAllocator::hintMemoryNotNeededSoon): 14 * wtf/OSAllocatorWin.cpp: 15 (WTF::OSAllocator::hintMemoryNotNeededSoon): 16 * wtf/Platform.h: 17 1 18 2015-12-16 Alex Christensen <achristensen@webkit.org> 2 19 -
trunk/Source/WTF/wtf/OSAllocator.h
r173949 r194204 70 70 template<typename T> 71 71 static T* reallocateCommitted(T*, size_t oldSize, size_t newSize, Usage = UnknownUsage, bool writable = true, bool executable = false); 72 73 // Hint to the OS that an address range is not expected to be accessed anytime soon. 74 WTF_EXPORT_PRIVATE static void hintMemoryNotNeededSoon(void*, size_t); 72 75 }; 73 76 -
trunk/Source/WTF/wtf/OSAllocatorPosix.cpp
r184245 r194204 165 165 } 166 166 167 void OSAllocator::hintMemoryNotNeededSoon(void* address, size_t bytes) 168 { 169 #if HAVE(MADV_DONTNEED) 170 while (madvise(address, bytes, MADV_DONTNEED) == -1 && errno == EAGAIN) { } 171 #else 172 UNUSED_PARAM(address); 173 UNUSED_PARAM(bytes); 174 #endif 175 } 176 167 177 void OSAllocator::releaseDecommitted(void* address, size_t bytes) 168 178 { -
trunk/Source/WTF/wtf/OSAllocatorWin.cpp
r174412 r194204 94 94 } 95 95 96 void OSAllocator::hintMemoryNotNeededSoon(void*, size_t) 97 { 98 } 99 96 100 } // namespace WTF 97 101 -
trunk/Source/WTF/wtf/Platform.h
r193873 r194204 631 631 #define HAVE_MADV_FREE 1 632 632 #define HAVE_MADV_FREE_REUSE 1 633 #define HAVE_MADV_DONTNEED 1 633 634 #define HAVE_MERGESORT 1 634 635 #define HAVE_PTHREAD_SETNAME_NP 1 -
trunk/Source/WebCore/ChangeLog
r194201 r194204 1 2015-12-16 Andreas Kling <akling@apple.com> 2 3 Give kernel VM some hints about non-live memory-cached resources. 4 <https://webkit.org/b/152362> 5 6 Reviewed by Geoffrey Garen. 7 8 When a file-backed CachedResource has no live clients left, and is only being kept alive 9 because it's cached in the MemoryCache, give the OS a hint that we probably won't need 10 that memory very soon. 11 12 Normally this doesn't do anything, but in case the system comes under memory pressure, 13 the kernel can prioritize eviction of such clean-but-unneeded pages, which prevents us 14 from throwing other processes under the bus too soon. 15 16 * loader/cache/CachedResource.cpp: 17 (WebCore::CachedResource::deleteIfPossible): 18 * platform/SharedBuffer.cpp: 19 (WebCore::SharedBuffer::hintMemoryNotNeededSoon): 20 * platform/SharedBuffer.h: 21 * platform/cf/SharedBufferCF.cpp: 22 (WebCore::SharedBuffer::hintMemoryNotNeededSoon): 23 1 24 2015-12-16 Gyuyoung Kim <gyuyoung.kim@webkit.org> 2 25 -
trunk/Source/WebCore/loader/cache/CachedResource.cpp
r194017 r194204 505 505 bool CachedResource::deleteIfPossible() 506 506 { 507 if (canDelete() && !inCache()) { 508 InspectorInstrumentation::willDestroyCachedResource(*this); 509 delete this; 510 return true; 507 if (canDelete()) { 508 if (!inCache()) { 509 InspectorInstrumentation::willDestroyCachedResource(*this); 510 delete this; 511 return true; 512 } 513 if (m_data) 514 m_data->hintMemoryNotNeededSoon(); 511 515 } 512 516 return false; -
trunk/Source/WebCore/platform/SharedBuffer.cpp
r185106 r194204 303 303 } 304 304 305 #if !USE(CF) 306 void SharedBuffer::hintMemoryNotNeededSoon() 307 { 308 } 309 #endif 310 305 311 #if !USE(NETWORK_CFDATA_ARRAY_CALLBACK) 306 312 -
trunk/Source/WebCore/platform/SharedBuffer.h
r194017 r194204 127 127 }; 128 128 129 void hintMemoryNotNeededSoon(); 130 129 131 private: 130 132 WEBCORE_EXPORT SharedBuffer(); -
trunk/Source/WebCore/platform/cf/SharedBufferCF.cpp
r194017 r194204 29 29 #include "SharedBuffer.h" 30 30 31 #include <wtf/OSAllocator.h> 31 32 #include <wtf/cf/TypeCastsCF.h> 32 33 … … 72 73 { 73 74 return CFDataGetLength(m_cfData.get()); 75 } 76 77 void SharedBuffer::hintMemoryNotNeededSoon() 78 { 79 if (!hasPlatformData()) 80 return; 81 OSAllocator::hintMemoryNotNeededSoon(const_cast<char*>(platformData()), platformDataSize()); 74 82 } 75 83
Note: See TracChangeset
for help on using the changeset viewer.