Bug 187919

Summary: Revert back to using phys_footprint to calculate isUnderMemoryPressure()
Product: WebKit Reporter: Saam Barati <saam>
Component: bmallocAssignee: Saam Barati <saam>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, commit-queue, ddkilzer, fpizlo, ggaren, gskachkov, jfbastien, joepeck, keith_miller, mark.lam, msaboff, rmorisset, rniwa, simon.fraser, ticaiolima, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
patch
saam: review-
patch none

Saam Barati
Reported 2018-07-23 13:19:07 PDT
Currently, we rely on bmalloc's physicalFootprint calculation. However, bmalloc may have a small or mediumish heap, but the process may be using a lot of dirty memory from elsewhere. It could still be helpful in preventing jetsam if bmalloc freed stuff.
Attachments
patch (4.86 KB, patch)
2018-07-23 17:43 PDT, Saam Barati
saam: review-
patch (2.90 KB, patch)
2018-07-24 17:41 PDT, Saam Barati
no flags
Saam Barati
Comment 1 2018-07-23 17:43:30 PDT
Simon Fraser (smfr)
Comment 2 2018-07-23 17:51:33 PDT
Comment on attachment 345630 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=345630&action=review > Source/bmalloc/bmalloc/Scavenger.cpp:136 > + task_vm_info_data_t vmInfo; > + mach_msg_type_number_t vmSize = TASK_VM_INFO_COUNT; > + if (KERN_SUCCESS == task_info(mach_task_self(), TASK_VM_INFO, (task_info_t)(&vmInfo), &vmSize)) > + return static_cast<double>(vmInfo.phys_footprint); > + return 0.0; Can this share code with memoryStatus()? > Source/bmalloc/bmalloc/Scavenger.cpp:140 > + if (osFootprint / hardwareMemoryCapacity > 0.9) > + return true; I don't know how to reason whether that 90% threshold is reasonable. If feels bad to not scavenge if we're using 800MB, because 800MB is huge.
Saam Barati
Comment 3 2018-07-23 17:57:03 PDT
Comment on attachment 345630 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=345630&action=review >> Source/bmalloc/bmalloc/Scavenger.cpp:136 >> + return 0.0; > > Can this share code with memoryStatus()? Yeah I can make it shared >> Source/bmalloc/bmalloc/Scavenger.cpp:140 >> + return true; > > I don't know how to reason whether that 90% threshold is reasonable. If feels bad to not scavenge if we're using 800MB, because 800MB is huge. This is just a heuristic. But specifically in this case, 800/840 > .9
Joseph Pecoraro
Comment 4 2018-07-23 19:53:40 PDT
Comment on attachment 345630 [details] patch This looks good to me.
Geoffrey Garen
Comment 5 2018-07-24 10:12:00 PDT
The logic of this code is getting pretty complicated, with multiple authors and multiple constraints we're trying to solve for. How do we know if we're making things better or worse?
Saam Barati
Comment 6 2018-07-24 11:39:10 PDT
(In reply to Geoffrey Garen from comment #5) > The logic of this code is getting pretty complicated, with multiple authors > and multiple constraints we're trying to solve for. > > How do we know if we're making things better or worse? When I implemented partial scavenging I manually verified we use less memory on average on the popular JS benchmarks. For this change, I don’t know of a way to validate it besides just thinking about certain heap shapes that might lead bmalloc to not return memory to the OS. Reasoning about this change, the only way I see it making things worse is by overscavenging when we’re close to the process’s memory limit. If that happens we’re in a world where we’re burning more CPU than necessary. However, it still seems better under that situation to spend CPU trying to free memory instead of allowing the process to jetsam
Radar WebKit Bug Importer
Comment 7 2018-07-24 13:04:48 PDT
Saam Barati
Comment 8 2018-07-24 17:41:15 PDT
WebKit Commit Bot
Comment 9 2018-07-24 19:09:52 PDT
Comment on attachment 345731 [details] patch Clearing flags on attachment: 345731 Committed r234185: <https://trac.webkit.org/changeset/234185>
WebKit Commit Bot
Comment 10 2018-07-24 19:09:54 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.