Title: [235295] releases/WebKitGTK/webkit-2.22/Source/WTF
- Revision
- 235295
- Author
- [email protected]
- Date
- 2018-08-24 01:08:22 -0700 (Fri, 24 Aug 2018)
Log Message
Merge r235113 - [Linux] Cache the memory footprint and only update it after 1 second
https://bugs.webkit.org/show_bug.cgi?id=188791
Reviewed by Yusuke Suzuki.
Getting the memory footprint is an expensive operation in Linux. When called multiple times, the CPU usage is
too much (see bug #188787). We could cache the result for at least 1 second to ensure we don't call it more than
once per second.
* wtf/linux/MemoryFootprintLinux.cpp:
(WTF::forEachLine):
(WTF::computeMemoryFootprint):
(WTF::memoryFootprint):
Modified Paths
Diff
Modified: releases/WebKitGTK/webkit-2.22/Source/WTF/ChangeLog (235294 => 235295)
--- releases/WebKitGTK/webkit-2.22/Source/WTF/ChangeLog 2018-08-24 08:08:17 UTC (rev 235294)
+++ releases/WebKitGTK/webkit-2.22/Source/WTF/ChangeLog 2018-08-24 08:08:22 UTC (rev 235295)
@@ -1,3 +1,19 @@
+2018-08-21 Carlos Garcia Campos <[email protected]>
+
+ [Linux] Cache the memory footprint and only update it after 1 second
+ https://bugs.webkit.org/show_bug.cgi?id=188791
+
+ Reviewed by Yusuke Suzuki.
+
+ Getting the memory footprint is an expensive operation in Linux. When called multiple times, the CPU usage is
+ too much (see bug #188787). We could cache the result for at least 1 second to ensure we don't call it more than
+ once per second.
+
+ * wtf/linux/MemoryFootprintLinux.cpp:
+ (WTF::forEachLine):
+ (WTF::computeMemoryFootprint):
+ (WTF::memoryFootprint):
+
2018-08-20 Saam barati <[email protected]>
Inline DataView accesses into DFG/FTL
Modified: releases/WebKitGTK/webkit-2.22/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp (235294 => 235295)
--- releases/WebKitGTK/webkit-2.22/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp 2018-08-24 08:08:17 UTC (rev 235294)
+++ releases/WebKitGTK/webkit-2.22/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp 2018-08-24 08:08:22 UTC (rev 235295)
@@ -27,6 +27,7 @@
#include "MemoryFootprint.h"
#if OS(LINUX)
+#include "MonotonicTime.h"
#include <stdio.h>
#include <wtf/StdLibExtras.h>
#include <wtf/text/StringView.h>
@@ -35,6 +36,8 @@
namespace WTF {
#if OS(LINUX)
+static const Seconds s_memoryFootprintUpdateInterval = 1_s;
+
template<typename Functor>
static void forEachLine(FILE* file, Functor functor)
{
@@ -45,11 +48,9 @@
}
free(buffer);
}
-#endif
-size_t memoryFootprint()
+static size_t computeMemoryFootprint()
{
-#if OS(LINUX)
FILE* file = fopen("/proc/self/smaps", "r");
if (!file)
return 0;
@@ -86,7 +87,22 @@
});
fclose(file);
return totalPrivateDirtyInKB * KB;
+}
#endif
+
+size_t memoryFootprint()
+{
+#if OS(LINUX)
+ static size_t footprint = 0;
+ static MonotonicTime previousUpdateTime = { };
+ Seconds elapsed = MonotonicTime::now() - previousUpdateTime;
+ if (elapsed >= s_memoryFootprintUpdateInterval) {
+ footprint = computeMemoryFootprint();
+ previousUpdateTime = MonotonicTime::now();
+ }
+
+ return footprint;
+#endif
return 0;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes