WebKit Bugzilla
Attachment 347635 Details for
Bug 188791
: [Linux] Cache the memory footprint and only update it after 1 second
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
wtf-memory-linux.diff (text/plain), 2.32 KB, created by
Carlos Garcia Campos
on 2018-08-21 06:02:18 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Carlos Garcia Campos
Created:
2018-08-21 06:02:18 PDT
Size:
2.32 KB
patch
obsolete
>diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index f933e476e6f..594359c9920 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,19 @@ >+2018-08-21 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [Linux] Cache the memory footprint and only update it after 1 second >+ https://bugs.webkit.org/show_bug.cgi?id=188791 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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-19 Yusuke Suzuki <yusukesuzuki@slowstart.org> > > [WTF] Add WTF::unalignedLoad and WTF::unalignedStore >diff --git a/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp b/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp >index f27658cc491..7bc9d7c77e4 100644 >--- a/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp >+++ b/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp >@@ -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 @@ static void forEachLine(FILE* file, Functor functor) > } > 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,6 +87,21 @@ size_t memoryFootprint() > }); > 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; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ysuzuki
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188791
: 347635