Changeset 276517 in webkit
- Timestamp:
- Apr 23, 2021, 2:29:59 PM (5 years ago)
- Location:
- branches/safari-611-branch/Source
- Files:
-
- 13 edited
-
JavaScriptCore/ChangeLog (modified) (1 diff)
-
JavaScriptCore/heap/BlockDirectory.cpp (modified) (2 diffs)
-
JavaScriptCore/heap/BlockDirectory.h (modified) (2 diffs)
-
JavaScriptCore/heap/FullGCActivityCallback.cpp (modified) (2 diffs)
-
JavaScriptCore/heap/Heap.cpp (modified) (1 diff)
-
JavaScriptCore/heap/Heap.h (modified) (1 diff)
-
JavaScriptCore/heap/MarkedSpace.cpp (modified) (2 diffs)
-
JavaScriptCore/heap/MarkedSpace.h (modified) (1 diff)
-
JavaScriptCore/runtime/OptionsList.h (modified) (1 diff)
-
WTF/ChangeLog (modified) (1 diff)
-
WTF/wtf/FunctionTraits.h (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/WebProcess/com.apple.WebProcess.sb.in (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-611-branch/Source/JavaScriptCore/ChangeLog
r276175 r276517 1 2021-04-23 Russell Epstein <repstein@apple.com> 2 3 Cherry-pick r276324. rdar://problem/77086404 4 5 FullGCActivityCallback should use the percentage of pages uncompressed in RAM to determine deferral. 6 https://bugs.webkit.org/show_bug.cgi?id=224817 7 8 Reviewed by Filip Pizlo. 9 10 Source/JavaScriptCore: 11 12 Right now we try to determine if too many pages are paged out by 13 dereferencing them and bailing out of the GC if we go over a 14 deadline. While this works if the only goal is to avoid causing 15 extensive thrashing on spinny disks (HDD), it doesn't prevent 16 thrashing when access to disk is fast (e.g. SSD). This is because 17 on fast disks the proportional time to load the memory from disk 18 is much lower. Additionally, on SSDs in particular we don't want 19 to load the pages into RAM then bail as that will force a 20 different page onto disk, increasing wear. 21 22 This patch switches to asking the OS if each MarkedBlock is paged 23 out. Then if we are over a threshold we wait until we would have 24 GC'd anyway. This patch uses the (maxVMGrowthFactor - 1) as the 25 percentage of "slow" pages (paged out or compressed) needed to 26 defer the GC. The idea behind that threshold is that if we add 27 that many pages then the same number of pages would be forced 28 out of RAM for us to do a GC anyway (in the limit). 29 30 * heap/BlockDirectory.cpp: 31 (JSC::BlockDirectory::updatePercentageOfPagedOutPages): 32 (JSC::BlockDirectory::isPagedOut): Deleted. 33 * heap/BlockDirectory.h: 34 * heap/FullGCActivityCallback.cpp: 35 (JSC::FullGCActivityCallback::doCollection): 36 * heap/Heap.cpp: 37 (JSC::Heap::isPagedOut): 38 * heap/Heap.h: 39 * heap/MarkedSpace.cpp: 40 (JSC::MarkedSpace::isPagedOut): 41 * heap/MarkedSpace.h: 42 * runtime/OptionsList.h: 43 44 Source/WebKit: 45 46 Add mincore to the acceptable syscall list. 47 48 * WebProcess/com.apple.WebProcess.sb.in: 49 50 Source/WTF: 51 52 Add a noexcept flavor of FunctionTraits. On Linux mincore (and probably other syscalls) are marked noexcept so the existing overloads don't work. 53 54 * wtf/FunctionTraits.h: 55 56 57 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276324 268f45cc-cd09-0410-ab3c-d52691b4dbfc 58 59 2021-04-20 Keith Miller <keith_miller@apple.com> 60 61 FullGCActivityCallback should use the percentage of pages uncompressed in RAM to determine deferral. 62 https://bugs.webkit.org/show_bug.cgi?id=224817 63 64 Reviewed by Filip Pizlo. 65 66 Right now we try to determine if too many pages are paged out by 67 dereferencing them and bailing out of the GC if we go over a 68 deadline. While this works if the only goal is to avoid causing 69 extensive thrashing on spinny disks (HDD), it doesn't prevent 70 thrashing when access to disk is fast (e.g. SSD). This is because 71 on fast disks the proportional time to load the memory from disk 72 is much lower. Additionally, on SSDs in particular we don't want 73 to load the pages into RAM then bail as that will force a 74 different page onto disk, increasing wear. 75 76 This patch switches to asking the OS if each MarkedBlock is paged 77 out. Then if we are over a threshold we wait until we would have 78 GC'd anyway. This patch uses the (maxVMGrowthFactor - 1) as the 79 percentage of "slow" pages (paged out or compressed) needed to 80 defer the GC. The idea behind that threshold is that if we add 81 that many pages then the same number of pages would be forced 82 out of RAM for us to do a GC anyway (in the limit). 83 84 * heap/BlockDirectory.cpp: 85 (JSC::BlockDirectory::updatePercentageOfPagedOutPages): 86 (JSC::BlockDirectory::isPagedOut): Deleted. 87 * heap/BlockDirectory.h: 88 * heap/FullGCActivityCallback.cpp: 89 (JSC::FullGCActivityCallback::doCollection): 90 * heap/Heap.cpp: 91 (JSC::Heap::isPagedOut): 92 * heap/Heap.h: 93 * heap/MarkedSpace.cpp: 94 (JSC::MarkedSpace::isPagedOut): 95 * heap/MarkedSpace.h: 96 * runtime/OptionsList.h: 97 1 98 2021-04-16 Alan Coon <alancoon@apple.com> 2 99 -
branches/safari-611-branch/Source/JavaScriptCore/heap/BlockDirectory.cpp
r276175 r276517 32 32 #include "SuperSampler.h" 33 33 34 #include <wtf/FunctionTraits.h> 35 #include <wtf/SimpleStats.h> 36 34 37 namespace JSC { 35 38 … … 54 57 } 55 58 56 bool BlockDirectory::isPagedOut(MonotonicTime deadline) 57 { 58 unsigned itersSinceLastTimeCheck = 0; 59 for (auto* block : m_blocks) { 60 if (block) 61 block->block().populatePage(); 62 ++itersSinceLastTimeCheck; 63 if (itersSinceLastTimeCheck >= Heap::s_timeCheckResolution) { 64 MonotonicTime currentTime = MonotonicTime::now(); 65 if (currentTime > deadline) 66 return true; 67 itersSinceLastTimeCheck = 0; 68 } 69 } 70 return false; 59 void BlockDirectory::updatePercentageOfPagedOutPages(SimpleStats& stats) 60 { 61 // FIXME: We should figure out a solution for Windows. 62 #if OS(UNIX) 63 size_t pageSize = WTF::pageSize(); 64 ASSERT(!(MarkedBlock::blockSize % pageSize)); 65 auto numberOfPagesInMarkedBlock = MarkedBlock::blockSize / pageSize; 66 // For some reason this can be unsigned char or char on different OSes... 67 using MincoreBufferType = std::remove_pointer_t<FunctionTraits<decltype(mincore)>::ArgumentType<2>>; 68 static_assert(std::is_same_v<std::make_unsigned_t<MincoreBufferType>, unsigned char>); 69 // pageSize is effectively a constant so this isn't really variable. 70 IGNORE_CLANG_WARNINGS_BEGIN("vla") 71 MincoreBufferType pagedBits[numberOfPagesInMarkedBlock]; 72 IGNORE_CLANG_WARNINGS_END 73 74 for (auto* handle : m_blocks) { 75 if (!handle) 76 continue; 77 78 auto markedBlockSizeInBytes = static_cast<size_t>(reinterpret_cast<char*>(handle->end()) - reinterpret_cast<char*>(handle->start())); 79 RELEASE_ASSERT(markedBlockSizeInBytes / pageSize <= numberOfPagesInMarkedBlock); 80 // We could cache this in bulk (e.g. 25 MB chunks) but we haven't seen any data that it actually matters. 81 auto result = mincore(handle->start(), markedBlockSizeInBytes, pagedBits); 82 RELEASE_ASSERT(!result); 83 constexpr unsigned pageIsResidentAndNotCompressed = 1; 84 for (unsigned i = 0; i < numberOfPagesInMarkedBlock; ++i) 85 stats.add(!(pagedBits[i] & pageIsResidentAndNotCompressed)); 86 } 87 #endif 71 88 } 72 89 -
branches/safari-611-branch/Source/JavaScriptCore/heap/BlockDirectory.h
r276175 r276517 37 37 #include <wtf/SharedTask.h> 38 38 #include <wtf/Vector.h> 39 40 namespace WTF { 41 class SimpleStats; 42 } 39 43 40 44 namespace JSC { … … 88 92 void removeBlock(MarkedBlock::Handle*, WillDeleteBlock = WillDeleteBlock::No); 89 93 90 bool isPagedOut(MonotonicTime deadline);94 void updatePercentageOfPagedOutPages(WTF::SimpleStats&); 91 95 92 96 Lock& bitvectorLock() { return m_bitvectorLock; } -
branches/safari-611-branch/Source/JavaScriptCore/heap/FullGCActivityCallback.cpp
r237266 r276517 31 31 namespace JSC { 32 32 33 #if !PLATFORM(IOS_FAMILY)34 const constexpr Seconds pagingTimeOut { 100_ms }; // Time in seconds to allow opportunistic timer to iterate over all blocks to see if the Heap is paged out.35 #endif36 37 33 FullGCActivityCallback::FullGCActivityCallback(Heap* heap) 38 34 : GCActivityCallback(heap) … … 45 41 m_didGCRecently = false; 46 42 47 #if !PLATFORM(IOS_FAMILY) 43 #if !PLATFORM(IOS_FAMILY) || PLATFORM(MACCATALYST) 48 44 MonotonicTime startTime = MonotonicTime::now(); 49 if (heap.isPagedOut( startTime + pagingTimeOut)) {45 if (heap.isPagedOut()) { 50 46 cancel(); 51 heap.increaseLastFullGCLength( pagingTimeOut);47 heap.increaseLastFullGCLength(MonotonicTime::now() - startTime); 52 48 return; 53 49 } -
branches/safari-611-branch/Source/JavaScriptCore/heap/Heap.cpp
r264743 r276517 355 355 } 356 356 357 bool Heap::isPagedOut( MonotonicTime deadline)358 { 359 return m_objectSpace.isPagedOut( deadline);357 bool Heap::isPagedOut() 358 { 359 return m_objectSpace.isPagedOut(); 360 360 } 361 361 -
branches/safari-611-branch/Source/JavaScriptCore/heap/Heap.h
r262562 r276517 272 272 273 273 void didAllocate(size_t); 274 bool isPagedOut( MonotonicTime deadline);274 bool isPagedOut(); 275 275 276 276 const JITStubRoutineSet& jitStubRoutines() { return *m_jitStubRoutines; } -
branches/safari-611-branch/Source/JavaScriptCore/heap/MarkedSpace.cpp
r276175 r276517 28 28 #include "MarkedSpaceInlines.h" 29 29 #include <wtf/ListDump.h> 30 #include <wtf/SimpleStats.h> 30 31 31 32 namespace JSC { … … 355 356 } 356 357 357 bool MarkedSpace::isPagedOut(MonotonicTime deadline) 358 { 359 bool result = false; 360 forEachDirectory( 361 [&] (BlockDirectory& directory) -> IterationStatus { 362 if (directory.isPagedOut(deadline)) { 363 result = true; 364 return IterationStatus::Done; 365 } 358 bool MarkedSpace::isPagedOut() 359 { 360 SimpleStats pagedOutPagesStats; 361 362 forEachDirectory( 363 [&] (BlockDirectory& directory) -> IterationStatus { 364 directory.updatePercentageOfPagedOutPages(pagedOutPagesStats); 366 365 return IterationStatus::Continue; 367 366 }); 368 367 // FIXME: Consider taking PreciseAllocations into account here. 369 return result; 368 double maxHeapGrowthFactor = VM::isInMiniMode() ? Options::miniVMHeapGrowthFactor() : Options::largeHeapGrowthFactor(); 369 double bailoutPercentage = Options::customFullGCCallbackBailThreshold() == -1.0 ? maxHeapGrowthFactor - 1 : Options::customFullGCCallbackBailThreshold(); 370 return pagedOutPagesStats.mean() > pagedOutPagesStats.count() * bailoutPercentage; 370 371 } 371 372 -
branches/safari-611-branch/Source/JavaScriptCore/heap/MarkedSpace.h
r262786 r276517 149 149 size_t capacity(); 150 150 151 bool isPagedOut( MonotonicTime deadline);151 bool isPagedOut(); 152 152 153 153 HeapVersion markingVersion() const { return m_markingVersion; } -
branches/safari-611-branch/Source/JavaScriptCore/runtime/OptionsList.h
r272940 r276517 199 199 v(Double, miniVMHeapGrowthFactor, 1.27, Normal, nullptr) \ 200 200 v(Double, criticalGCMemoryThreshold, 0.80, Normal, "percent memory in use the GC considers critical. The collector is much more aggressive above this threshold") \ 201 v(Double, customFullGCCallbackBailThreshold, -1.0, Normal, "percent of memory paged out before we bail out of timer based Full GCs. -1.0 means use (maxHeapGrowthFactor - 1)") \ 201 202 v(Double, minimumMutatorUtilization, 0, Normal, nullptr) \ 202 203 v(Double, maximumMutatorUtilization, 0.7, Normal, nullptr) \ -
branches/safari-611-branch/Source/WTF/ChangeLog
r276063 r276517 1 2021-04-23 Russell Epstein <repstein@apple.com> 2 3 Cherry-pick r276324. rdar://problem/77086404 4 5 FullGCActivityCallback should use the percentage of pages uncompressed in RAM to determine deferral. 6 https://bugs.webkit.org/show_bug.cgi?id=224817 7 8 Reviewed by Filip Pizlo. 9 10 Source/JavaScriptCore: 11 12 Right now we try to determine if too many pages are paged out by 13 dereferencing them and bailing out of the GC if we go over a 14 deadline. While this works if the only goal is to avoid causing 15 extensive thrashing on spinny disks (HDD), it doesn't prevent 16 thrashing when access to disk is fast (e.g. SSD). This is because 17 on fast disks the proportional time to load the memory from disk 18 is much lower. Additionally, on SSDs in particular we don't want 19 to load the pages into RAM then bail as that will force a 20 different page onto disk, increasing wear. 21 22 This patch switches to asking the OS if each MarkedBlock is paged 23 out. Then if we are over a threshold we wait until we would have 24 GC'd anyway. This patch uses the (maxVMGrowthFactor - 1) as the 25 percentage of "slow" pages (paged out or compressed) needed to 26 defer the GC. The idea behind that threshold is that if we add 27 that many pages then the same number of pages would be forced 28 out of RAM for us to do a GC anyway (in the limit). 29 30 * heap/BlockDirectory.cpp: 31 (JSC::BlockDirectory::updatePercentageOfPagedOutPages): 32 (JSC::BlockDirectory::isPagedOut): Deleted. 33 * heap/BlockDirectory.h: 34 * heap/FullGCActivityCallback.cpp: 35 (JSC::FullGCActivityCallback::doCollection): 36 * heap/Heap.cpp: 37 (JSC::Heap::isPagedOut): 38 * heap/Heap.h: 39 * heap/MarkedSpace.cpp: 40 (JSC::MarkedSpace::isPagedOut): 41 * heap/MarkedSpace.h: 42 * runtime/OptionsList.h: 43 44 Source/WebKit: 45 46 Add mincore to the acceptable syscall list. 47 48 * WebProcess/com.apple.WebProcess.sb.in: 49 50 Source/WTF: 51 52 Add a noexcept flavor of FunctionTraits. On Linux mincore (and probably other syscalls) are marked noexcept so the existing overloads don't work. 53 54 * wtf/FunctionTraits.h: 55 56 57 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276324 268f45cc-cd09-0410-ab3c-d52691b4dbfc 58 59 2021-04-20 Keith Miller <keith_miller@apple.com> 60 61 FullGCActivityCallback should use the percentage of pages uncompressed in RAM to determine deferral. 62 https://bugs.webkit.org/show_bug.cgi?id=224817 63 64 Reviewed by Filip Pizlo. 65 66 Add a noexcept flavor of FunctionTraits. On Linux mincore (and probably other syscalls) are marked noexcept so the existing overloads don't work. 67 68 * wtf/FunctionTraits.h: 69 1 70 2021-04-08 Russell Epstein <repstein@apple.com> 2 71 -
branches/safari-611-branch/Source/WTF/wtf/FunctionTraits.h
r233504 r276517 81 81 }; 82 82 83 template<typename Result, typename... Args> 84 struct FunctionTraits<Result(Args...) noexcept> : public FunctionTraits<Result(Args...)> { 85 }; 86 87 template<typename Result, typename... Args> 88 struct FunctionTraits<Result(*)(Args...) noexcept> : public FunctionTraits<Result(Args...)> { 89 }; 90 83 91 } // namespace WTF 84 92 -
branches/safari-611-branch/Source/WebKit/ChangeLog
r276501 r276517 1 2021-04-23 Russell Epstein <repstein@apple.com> 2 3 Cherry-pick r276324. rdar://problem/77086404 4 5 FullGCActivityCallback should use the percentage of pages uncompressed in RAM to determine deferral. 6 https://bugs.webkit.org/show_bug.cgi?id=224817 7 8 Reviewed by Filip Pizlo. 9 10 Source/JavaScriptCore: 11 12 Right now we try to determine if too many pages are paged out by 13 dereferencing them and bailing out of the GC if we go over a 14 deadline. While this works if the only goal is to avoid causing 15 extensive thrashing on spinny disks (HDD), it doesn't prevent 16 thrashing when access to disk is fast (e.g. SSD). This is because 17 on fast disks the proportional time to load the memory from disk 18 is much lower. Additionally, on SSDs in particular we don't want 19 to load the pages into RAM then bail as that will force a 20 different page onto disk, increasing wear. 21 22 This patch switches to asking the OS if each MarkedBlock is paged 23 out. Then if we are over a threshold we wait until we would have 24 GC'd anyway. This patch uses the (maxVMGrowthFactor - 1) as the 25 percentage of "slow" pages (paged out or compressed) needed to 26 defer the GC. The idea behind that threshold is that if we add 27 that many pages then the same number of pages would be forced 28 out of RAM for us to do a GC anyway (in the limit). 29 30 * heap/BlockDirectory.cpp: 31 (JSC::BlockDirectory::updatePercentageOfPagedOutPages): 32 (JSC::BlockDirectory::isPagedOut): Deleted. 33 * heap/BlockDirectory.h: 34 * heap/FullGCActivityCallback.cpp: 35 (JSC::FullGCActivityCallback::doCollection): 36 * heap/Heap.cpp: 37 (JSC::Heap::isPagedOut): 38 * heap/Heap.h: 39 * heap/MarkedSpace.cpp: 40 (JSC::MarkedSpace::isPagedOut): 41 * heap/MarkedSpace.h: 42 * runtime/OptionsList.h: 43 44 Source/WebKit: 45 46 Add mincore to the acceptable syscall list. 47 48 * WebProcess/com.apple.WebProcess.sb.in: 49 50 Source/WTF: 51 52 Add a noexcept flavor of FunctionTraits. On Linux mincore (and probably other syscalls) are marked noexcept so the existing overloads don't work. 53 54 * wtf/FunctionTraits.h: 55 56 57 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276324 268f45cc-cd09-0410-ab3c-d52691b4dbfc 58 59 2021-04-20 Keith Miller <keith_miller@apple.com> 60 61 FullGCActivityCallback should use the percentage of pages uncompressed in RAM to determine deferral. 62 https://bugs.webkit.org/show_bug.cgi?id=224817 63 64 Reviewed by Filip Pizlo. 65 66 Add mincore to the acceptable syscall list. 67 68 * WebProcess/com.apple.WebProcess.sb.in: 69 1 70 2021-04-23 Russell Epstein <repstein@apple.com> 2 71 -
branches/safari-611-branch/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in
r276400 r276517 1516 1516 (syscall-number SYS_mprotect) 1517 1517 (syscall-number SYS_madvise) 1518 (syscall-number SYS_mincore) 1518 1519 (syscall-number SYS_fcntl) 1519 1520 (syscall-number SYS_select)
Note:
See TracChangeset
for help on using the changeset viewer.