WebKit Bugzilla
Attachment 345906 Details for
Bug 188091
: Use SPI to compute the jetsam limit on iOS instead of hardcoding 840MB
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
c-backup.diff (text/plain), 5.21 KB, created by
Saam Barati
on 2018-07-26 23:56:05 PDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Saam Barati
Created:
2018-07-26 23:56:05 PDT
Size:
5.21 KB
patch
obsolete
>Index: Source/WebKit/ChangeLog >=================================================================== >--- Source/WebKit/ChangeLog (revision 234308) >+++ Source/WebKit/ChangeLog (working copy) >@@ -1,3 +1,15 @@ >+2018-07-26 Saam Barati <sbarati@apple.com> >+ >+ Use SPI to compute the jetsam limit on iOS instead of hardcoding 840MB >+ https://bugs.webkit.org/show_bug.cgi?id=188091 >+ <rdar://problem/42647697> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Configurations/Databases-iOS.entitlements: >+ * Configurations/Network-iOS.entitlements: >+ * Configurations/WebContent-iOS.entitlements: >+ > 2018-07-26 Andy VanWagoner <andy@vanwagoner.family> > > [INTL] Remove INTL sub-feature compile flags >Index: Source/WebKit/Configurations/Databases-iOS.entitlements >=================================================================== >--- Source/WebKit/Configurations/Databases-iOS.entitlements (revision 234308) >+++ Source/WebKit/Configurations/Databases-iOS.entitlements (working copy) >@@ -6,5 +6,7 @@ > <array> > <string>com.apple.WebKit.Storage</string> > </array> >+ <key>com.apple.private.memorystatus</key> >+ <true/> > </dict> > </plist> >Index: Source/WebKit/Configurations/Network-iOS.entitlements >=================================================================== >--- Source/WebKit/Configurations/Network-iOS.entitlements (revision 234308) >+++ Source/WebKit/Configurations/Network-iOS.entitlements (working copy) >@@ -16,5 +16,7 @@ > <array> > <string>com.apple.WebKit.Networking</string> > </array> >+ <key>com.apple.private.memorystatus</key> >+ <true/> > </dict> > </plist> >Index: Source/WebKit/Configurations/WebContent-iOS.entitlements >=================================================================== >--- Source/WebKit/Configurations/WebContent-iOS.entitlements (revision 234308) >+++ Source/WebKit/Configurations/WebContent-iOS.entitlements (working copy) >@@ -29,5 +29,7 @@ > <string>kTCCServiceMicrophone</string> > <string>kTCCServiceCamera</string> > </array> >+ <key>com.apple.private.memorystatus</key> >+ <true/> > </dict> > </plist> >Index: Source/bmalloc/ChangeLog >=================================================================== >--- Source/bmalloc/ChangeLog (revision 234308) >+++ Source/bmalloc/ChangeLog (working copy) >@@ -1,3 +1,25 @@ >+2018-07-26 Saam Barati <sbarati@apple.com> >+ >+ Use SPI to compute the jetsam limit on iOS instead of hardcoding 840MB >+ https://bugs.webkit.org/show_bug.cgi?id=188091 >+ <rdar://problem/42647697> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ We want bmalloc to dynamically adapt to the jetsam limit of the process >+ it's running in. WTF::ramSize() is based off bmalloc's availableMemory, >+ so it will now reflect the result of the real jetsam limit when we can >+ read it. >+ >+ Reading the jetsam limit requires an entitlement, so this patch opts in >+ the WebContent/Storage/Network processes. We fall back to 840MB (the >+ old hard coded value) when the SPI call fails (e.g, when we're in a >+ process without the proper entitlement). >+ >+ * bmalloc/AvailableMemory.cpp: >+ (bmalloc::jetsamLimit): >+ (bmalloc::computeAvailableMemory): >+ > 2018-07-24 Saam Barati <sbarati@apple.com> > > Revert back to using phys_footprint to calculate isUnderMemoryPressure() >Index: Source/bmalloc/bmalloc/AvailableMemory.cpp >=================================================================== >--- Source/bmalloc/bmalloc/AvailableMemory.cpp (revision 234308) >+++ Source/bmalloc/bmalloc/AvailableMemory.cpp (working copy) >@@ -43,6 +43,32 @@ > #include <unistd.h> > #endif > >+#if BPLATFORM(IOS) >+#if __has_include(<System/sys/kern_memorystatus.h>) >+extern "C" { >+#include <System/sys/kern_memorystatus.h> >+} >+#else >+extern "C" { >+ >+typedef struct memorystatus_memlimit_properties { >+ int32_t memlimit_active; /* jetsam memory limit (in MB) when process is active */ >+ uint32_t memlimit_active_attr; >+ int32_t memlimit_inactive; /* jetsam memory limit (in MB) when process is inactive */ >+ uint32_t memlimit_inactive_attr; >+} memorystatus_memlimit_properties_t; >+ >+#define MEMORYSTATUS_CMD_GET_MEMLIMIT_PROPERTIES 8 >+ >+} >+#endif // __has_include(<System/sys/kern_memorystatus.h>) >+ >+extern "C" { >+int memorystatus_control(uint32_t command, int32_t pid, uint32_t flags, void *buffer, size_t buffersize); >+} >+ >+#endif // BPLATFORM(IOS) >+ > namespace bmalloc { > > static const size_t availableMemoryGuess = 512 * bmalloc::MB; >@@ -72,12 +98,23 @@ static size_t memorySizeAccordingToKerne > } > #endif > >+#if BPLATFORM(IOS) >+static size_t jetsamLimit() >+{ >+ memorystatus_memlimit_properties_t properties; >+ pid_t pid = getpid(); >+ if (memorystatus_control(MEMORYSTATUS_CMD_GET_MEMLIMIT_PROPERTIES, pid, 0, &properties, sizeof(properties))) >+ return 840 * bmalloc::MB; >+ return static_cast<size_t>(properties.memlimit_active) * bmalloc::MB; >+} >+#endif >+ > static size_t computeAvailableMemory() > { > #if BOS(DARWIN) > size_t sizeAccordingToKernel = memorySizeAccordingToKernel(); > #if BPLATFORM(IOS) >- sizeAccordingToKernel = std::min(sizeAccordingToKernel, 840 * bmalloc::MB); >+ sizeAccordingToKernel = std::min(sizeAccordingToKernel, jetsamLimit()); > #endif > size_t multiple = 128 * bmalloc::MB; >
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:
simon.fraser
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188091
:
345903
|
345904
|
345905
|
345906
|
345932
|
345940