Changeset 235113 in webkit
- Timestamp:
- Aug 21, 2018 6:27:42 AM (6 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r235106 r235113 1 2018-08-21 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [Linux] Cache the memory footprint and only update it after 1 second 4 https://bugs.webkit.org/show_bug.cgi?id=188791 5 6 Reviewed by Yusuke Suzuki. 7 8 Getting the memory footprint is an expensive operation in Linux. When called multiple times, the CPU usage is 9 too much (see bug #188787). We could cache the result for at least 1 second to ensure we don't call it more than 10 once per second. 11 12 * wtf/linux/MemoryFootprintLinux.cpp: 13 (WTF::forEachLine): 14 (WTF::computeMemoryFootprint): 15 (WTF::memoryFootprint): 16 1 17 2018-08-20 Saam barati <sbarati@apple.com> 2 18 -
trunk/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp
r234733 r235113 28 28 29 29 #if OS(LINUX) 30 #include "MonotonicTime.h" 30 31 #include <stdio.h> 31 32 #include <wtf/StdLibExtras.h> … … 36 37 37 38 #if OS(LINUX) 39 static const Seconds s_memoryFootprintUpdateInterval = 1_s; 40 38 41 template<typename Functor> 39 42 static void forEachLine(FILE* file, Functor functor) … … 46 49 free(buffer); 47 50 } 48 #endif49 51 50 s ize_t memoryFootprint()52 static size_t computeMemoryFootprint() 51 53 { 52 #if OS(LINUX)53 54 FILE* file = fopen("/proc/self/smaps", "r"); 54 55 if (!file) … … 87 88 fclose(file); 88 89 return totalPrivateDirtyInKB * KB; 90 } 91 #endif 92 93 size_t memoryFootprint() 94 { 95 #if OS(LINUX) 96 static size_t footprint = 0; 97 static MonotonicTime previousUpdateTime = { }; 98 Seconds elapsed = MonotonicTime::now() - previousUpdateTime; 99 if (elapsed >= s_memoryFootprintUpdateInterval) { 100 footprint = computeMemoryFootprint(); 101 previousUpdateTime = MonotonicTime::now(); 102 } 103 104 return footprint; 89 105 #endif 90 106 return 0;
Note: See TracChangeset
for help on using the changeset viewer.