RESOLVED FIXED 171944
[iOS] Use memory footprint to dynamically adjust behavior of allocators
https://bugs.webkit.org/show_bug.cgi?id=171944
Summary [iOS] Use memory footprint to dynamically adjust behavior of allocators
Michael Saboff
Reported 2017-05-10 13:54:52 PDT
On iOS, there is a soft memory limit of 840MB for WebContent processes. When we get close to or above that limit and don’t reduce memory usage it is likely the OS will jetsam the process. The OS provides memory pressure notifications, but that mechanism is course and may not provide a timely way to modify behavior. It makes more sense to modify our allocation policies and return free memory back to the OS more agressively as we approach our memory limit. <rdar://problem/32116376>
Attachments
Almost done patch for review (16.82 KB, patch)
2017-05-10 14:45 PDT, Michael Saboff
fpizlo: review+
Updated patch - should fix build issues. (27.36 KB, patch)
2017-05-11 11:15 PDT, Michael Saboff
no flags
Patch with another build fix (27.36 KB, patch)
2017-05-11 11:28 PDT, Michael Saboff
no flags
Another build fix for EWS to try (28.73 KB, patch)
2017-05-11 12:10 PDT, Michael Saboff
no flags
Another build fix. Moved AvailableMemory files to stdlib and added the .cpp to CMakeLists.txt (29.32 KB, patch)
2017-05-11 12:35 PDT, Michael Saboff
no flags
Hopefully last EWS patch - Moved AvailableMemory.{cpp, h} into main bmalloc directory. (29.25 KB, patch)
2017-05-11 16:00 PDT, Michael Saboff
no flags
Another speculative GTK build fix. Eliminated Darwin conditional inclusion of AvailableMemory.h in bmalloc.h (29.23 KB, patch)
2017-05-11 16:07 PDT, Michael Saboff
no flags
Speculative GTK build fix (29.41 KB, patch)
2017-05-11 16:16 PDT, Michael Saboff
no flags
Another speculative GTK build fix. Eliminated Darwin conditional inclusion of AvailableMemory.h in bmalloc.h (29.40 KB, patch)
2017-05-11 16:52 PDT, Michael Saboff
buildbot: commit-queue-
Archive of layout-test-results from ews113 for mac-elcapitan (1.77 MB, application/zip)
2017-05-11 18:48 PDT, Build Bot
no flags
Michael Saboff
Comment 1 2017-05-10 14:45:51 PDT
Created attachment 309640 [details] Almost done patch for review My only question is how to layer bmalloc and WTF. Currently bmalloc uses ramSize() from WTF, but I could be convinced to move ramSize to bmalloc. I'm open to other ideas as well.
Filip Pizlo
Comment 2 2017-05-10 16:08:50 PDT
Comment on attachment 309640 [details] Almost done patch for review View in context: https://bugs.webkit.org/attachment.cgi?id=309640&action=review This looks good to me! > Source/JavaScriptCore/heap/Heap.cpp:117 > + size_t memoryFootprint = bmalloc::api::memoryFootprint(); Would be cool if bmalloc::api::memoryFootprint was abstracted in WTF behind fastMallocMemoryFootprint, or something. Not super important. > Source/bmalloc/bmalloc/Heap.cpp:45 > +#if BPLATFORM(IOS) > +namespace WTF { > + > +size_t ramSize(); > + > +} > +#endif Would be a lot better if you moved WTF::ramSize into bmalloc, and then WTF::ramSize would be a forwarding function that calls bmalloc::api::ramSize or whatever.
Michael Saboff
Comment 3 2017-05-11 11:15:59 PDT
Created attachment 309728 [details] Updated patch - should fix build issues. (In reply to Filip Pizlo from comment #2) > Comment on attachment 309640 [details] > Almost done patch for review > > View in context: > https://bugs.webkit.org/attachment.cgi?id=309640&action=review > > This looks good to me! > > > Source/JavaScriptCore/heap/Heap.cpp:117 > > + size_t memoryFootprint = bmalloc::api::memoryFootprint(); > > Would be cool if bmalloc::api::memoryFootprint was abstracted in WTF behind > fastMallocMemoryFootprint, or something. > > Not super important. I'll do this is in a followup patch. > > Source/bmalloc/bmalloc/Heap.cpp:45 > > +#if BPLATFORM(IOS) > > +namespace WTF { > > + > > +size_t ramSize(); > > + > > +} > > +#endif > > Would be a lot better if you moved WTF::ramSize into bmalloc, and then > WTF::ramSize would be a forwarding function that calls bmalloc::api::ramSize > or whatever. Done.
Build Bot
Comment 4 2017-05-11 11:17:41 PDT
Attachment 309728 [details] did not pass style-queue: ERROR: Source/bmalloc/bmalloc/Heap.cpp:38: Alphabetical sorting problem. [build/include_order] [4] ERROR: Source/bmalloc/bmalloc/darwin/AvailableMemory.cpp:26: Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted. [build/include_order] [4] Total errors found: 2 in 15 files If any of these errors are false positives, please file a bug against check-webkit-style.
Michael Saboff
Comment 5 2017-05-11 11:28:19 PDT
Created attachment 309731 [details] Patch with another build fix
Build Bot
Comment 6 2017-05-11 11:29:39 PDT
Attachment 309731 [details] did not pass style-queue: ERROR: Source/bmalloc/bmalloc/Heap.cpp:38: Alphabetical sorting problem. [build/include_order] [4] ERROR: Source/bmalloc/bmalloc/darwin/AvailableMemory.cpp:26: Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted. [build/include_order] [4] Total errors found: 2 in 15 files If any of these errors are false positives, please file a bug against check-webkit-style.
Michael Saboff
Comment 7 2017-05-11 12:10:44 PDT
Created attachment 309747 [details] Another build fix for EWS to try
Build Bot
Comment 8 2017-05-11 12:11:38 PDT
Attachment 309747 [details] did not pass style-queue: ERROR: Source/bmalloc/bmalloc/Heap.cpp:38: Alphabetical sorting problem. [build/include_order] [4] ERROR: Source/bmalloc/bmalloc/darwin/AvailableMemory.cpp:26: Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted. [build/include_order] [4] Total errors found: 2 in 16 files If any of these errors are false positives, please file a bug against check-webkit-style.
Michael Saboff
Comment 9 2017-05-11 12:35:33 PDT
Created attachment 309752 [details] Another build fix. Moved AvailableMemory files to stdlib and added the .cpp to CMakeLists.txt
Build Bot
Comment 10 2017-05-11 12:36:39 PDT
Attachment 309752 [details] did not pass style-queue: ERROR: Source/bmalloc/bmalloc/Heap.cpp:38: Alphabetical sorting problem. [build/include_order] [4] ERROR: Source/bmalloc/bmalloc/darwin/AvailableMemory.cpp:26: Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted. [build/include_order] [4] Total errors found: 2 in 17 files If any of these errors are false positives, please file a bug against check-webkit-style.
Michael Saboff
Comment 11 2017-05-11 16:00:23 PDT
Created attachment 309804 [details] Hopefully last EWS patch - Moved AvailableMemory.{cpp, h} into main bmalloc directory.
Build Bot
Comment 12 2017-05-11 16:03:13 PDT
Attachment 309804 [details] did not pass style-queue: ERROR: Source/bmalloc/bmalloc/Heap.cpp:38: Alphabetical sorting problem. [build/include_order] [4] ERROR: Source/bmalloc/bmalloc/AvailableMemory.cpp:26: Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted. [build/include_order] [4] Total errors found: 2 in 17 files If any of these errors are false positives, please file a bug against check-webkit-style.
Michael Saboff
Comment 13 2017-05-11 16:07:30 PDT
Created attachment 309807 [details] Another speculative GTK build fix. Eliminated Darwin conditional inclusion of AvailableMemory.h in bmalloc.h
Build Bot
Comment 14 2017-05-11 16:08:17 PDT
Attachment 309807 [details] did not pass style-queue: ERROR: Source/bmalloc/bmalloc/Heap.cpp:38: Alphabetical sorting problem. [build/include_order] [4] ERROR: Source/bmalloc/bmalloc/bmalloc.h:30: Alphabetical sorting problem. [build/include_order] [4] ERROR: Source/bmalloc/bmalloc/AvailableMemory.cpp:26: Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted. [build/include_order] [4] Total errors found: 3 in 17 files If any of these errors are false positives, please file a bug against check-webkit-style.
Michael Saboff
Comment 15 2017-05-11 16:16:26 PDT
Created attachment 309811 [details] Speculative GTK build fix
Build Bot
Comment 16 2017-05-11 16:18:07 PDT
Attachment 309811 [details] did not pass style-queue: ERROR: Source/bmalloc/bmalloc/AvailableMemory.cpp:26: Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted. [build/include_order] [4] Total errors found: 1 in 17 files If any of these errors are false positives, please file a bug against check-webkit-style.
Michael Saboff
Comment 17 2017-05-11 16:52:14 PDT
Created attachment 309823 [details] Another speculative GTK build fix. Eliminated Darwin conditional inclusion of AvailableMemory.h in bmalloc.h
Build Bot
Comment 18 2017-05-11 16:56:59 PDT
Attachment 309823 [details] did not pass style-queue: ERROR: Source/bmalloc/bmalloc/AvailableMemory.cpp:26: Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted. [build/include_order] [4] Total errors found: 1 in 17 files If any of these errors are false positives, please file a bug against check-webkit-style.
Build Bot
Comment 19 2017-05-11 18:48:13 PDT
Comment on attachment 309823 [details] Another speculative GTK build fix. Eliminated Darwin conditional inclusion of AvailableMemory.h in bmalloc.h Attachment 309823 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/3722299 New failing tests: fast/workers/dedicated-worker-lifecycle.html
Build Bot
Comment 20 2017-05-11 18:48:15 PDT
Created attachment 309844 [details] Archive of layout-test-results from ews113 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews113 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Mark Lam
Comment 21 2017-05-11 19:19:47 PDT
(In reply to Build Bot from comment #19) > New failing tests: > fast/workers/dedicated-worker-lifecycle.html FYI, this is not your failure.
Michael Saboff
Comment 22 2017-05-12 07:15:10 PDT
Geoffrey Garen
Comment 23 2017-05-13 09:16:36 PDT
This looks like a 1% regression on the MBP and MBA JetStream bots. I suspect the change to speed up the scavenger is the cause, since the rest of this code shouldn't run on Mac.
Michael Saboff
Comment 24 2017-05-15 09:41:38 PDT
(In reply to Geoffrey Garen from comment #23) > This looks like a 1% regression on the MBP and MBA JetStream bots. > > I suspect the change to speed up the scavenger is the cause, since the rest > of this code shouldn't run on Mac. In addition to the scavenger delay being reduced to 250ms, the scavenger thread QOS was changed from QOS_CLASS_UNSPECIFIED to QOS_CLASS_USER_INITIATED. I agree though that the likely reason is cutting the delay in half. I'll check locally and post a followup patch. Tracked in <https://bugs.webkit.org/show_bug.cgi?id=172124>
Note You need to log in before you can comment on or make changes to this bug.