New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 590975 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner: ----
Closed: Mar 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug



Sign in to add a comment

GC triggered by memory pressure is postponed if V8 is busy

Project Member Reported by hong.zh...@intel.com, Mar 1 2016

Issue description

Steps to reproduce the problem:
1. surfing on low end Android device, like Samsung Galaxy Core2
2. after long time surfing, system memory becomes pressured and chrome will receive memory pressure notification
3. if V8 is in the middle of execution, renderer main thread has to postpone triggering V8 GC until V8 execution is finished, which increase OOM risk
more discussion about the bug in below link:
https://groups.google.com/a/chromium.org/forum/#!topic/project-trim/u_5DDPBXK74

What is the expected behavior?
V8 can do GC ASAP if memory is pressured

What went wrong?
V8 doesn't do GC ASAP, which can increase OOM risk

Did this work before? N/A 

Chrome version: 48.0.2564.116  Channel: n/a
OS Version: 6.3
Flash Version: Shockwave Flash 20.0 r0

For example, from the attachments we can see, in www.airbnb.com webpage, OnMemoryPressure has about 1000ms lag

The solution is WIP, I will update status soon
 
trace.airbnb.html
4.2 MB View Download
part-airbnb-trace.png
93.0 KB View Download
The CL to reduce V8 GC lag:
https://codereview.chromium.org/1749073002
From the attachment, we can see the CL does V8 GC about 1700ms earlier than OnMemoryPressure
CL-www.airbnb.com.html
7.0 MB View Download
CL-airbnb.png
330 KB View Download
I collected some traces with the CL in some web page, in which we found OnMemoryPressure had big lag(https://groups.google.com/a/chromium.org/d/msg/project-trim/u_5DDPBXK74/MPebAZSrAwAJ)
From the trace we can see the CL reduces V8 GC lag obviously when memory is pressured
CL-lag.png
19.1 KB View Download
www.aol.com-12,464.html
7.1 MB View Download
www.amazon.co.jp-31,405.html
6.6 MB View Download
www.imdb.com-9,005.html
6.6 MB View Download
www.taobao.com-9,376.html
4.8 MB View Download
Components: Blink>JavaScript
Based on CL 1749073002 and 1813963002, I did some experiments and obtained some positive results, like below images
critical.png
134 KB View Download
moderate.png
179 KB View Download
Trace about critical memory pressure notification
critical.html
8.3 MB View Download
Trace about moderate memory pressure notification
moderate.html
6.7 MB View Download
Cc: jochen@chromium.org
Does the MajorGC in those pages have a noticeable impact in memory usage? I'm curious how much doing the GC sooner really mattered.
Is there API or tool to count the memory usage in V8? If yes, I would like to verify the impact.
V8 is hooked up to the memory-infra tracing category.

Long term, it's not sustainable to rely on memory pressure to ensure that we don't die.


To add some more context: it might be that the system runs out of memory before v8 finishes the incremental GC. But if that happens, v8 didn't have the right memory limits configured. Doing a forced GC works around this issue, but doesn't solve it.

Since the amount of available memory changes over time, the pressure notifications should come with a memory limit. Then v8 could decide based on the limit and current usage what to do, and can tune it's parameters to stay below the limit going forward.
Cc: u...@chromium.org
Components: -Blink>JavaScript Blink>JavaScript>GC
Status: Available (was: Unconfirmed)
Project Member

Comment 17 by bugdroid1@chromium.org, May 3 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f80422e52658fd87d4159bfeeddd703bae1d4180

commit f80422e52658fd87d4159bfeeddd703bae1d4180
Author: hong.zheng <hong.zheng@intel.com>
Date: Tue May 03 04:23:37 2016

Do V8 GC ASAP if system memory is pressured

Currently after receiving memory pressure notification, Chrome posts
asynchronous task to renderer main thread to trigger V8 GC. If renderer
main thread is busy, purging memory task will be postponed running,
which increases OOM risk.

The CL can send memory pressure notification to renderer main thread
synchronously and trigger V8 GC while V8 is in the middle of executing
JavaScript.

The CL depends on CL 1813963002

BUG= 590975 

Review-Url: https://codereview.chromium.org/1749073002
Cr-Commit-Position: refs/heads/master@{#391167}

[modify] https://crrev.com/f80422e52658fd87d4159bfeeddd703bae1d4180/base/memory/memory_pressure_listener.cc
[modify] https://crrev.com/f80422e52658fd87d4159bfeeddd703bae1d4180/base/memory/memory_pressure_listener.h
[modify] https://crrev.com/f80422e52658fd87d4159bfeeddd703bae1d4180/content/renderer/render_thread_impl.cc
[modify] https://crrev.com/f80422e52658fd87d4159bfeeddd703bae1d4180/content/renderer/render_thread_impl.h
[modify] https://crrev.com/f80422e52658fd87d4159bfeeddd703bae1d4180/third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp
[modify] https://crrev.com/f80422e52658fd87d4159bfeeddd703bae1d4180/third_party/WebKit/Source/core/workers/WorkerBackingThread.h
[modify] https://crrev.com/f80422e52658fd87d4159bfeeddd703bae1d4180/third_party/WebKit/Source/web/WebKit.cpp
[modify] https://crrev.com/f80422e52658fd87d4159bfeeddd703bae1d4180/third_party/WebKit/public/web/WebKit.h

Project Member

Comment 18 by bugdroid1@chromium.org, May 4 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/78980b9332da0264f52bd4ff0b6aeef23cdc21e9

commit 78980b9332da0264f52bd4ff0b6aeef23cdc21e9
Author: vitalybuka <vitalybuka@chromium.org>
Date: Wed May 04 20:50:48 2016

Revert of Do V8 GC ASAP if system memory is pressured (patchset #13 id:240001 of https://codereview.chromium.org/1749073002/ )

Reason for revert:
Crash in CallOnForegroundThread
BUG=609056

Original issue's description:
> Do V8 GC ASAP if system memory is pressured
>
> Currently after receiving memory pressure notification, Chrome posts
> asynchronous task to renderer main thread to trigger V8 GC. If renderer
> main thread is busy, purging memory task will be postponed running,
> which increases OOM risk.
>
> The CL can send memory pressure notification to renderer main thread
> synchronously and trigger V8 GC while V8 is in the middle of executing
> JavaScript.
>
> The CL depends on CL 1813963002
>
> BUG= 590975 
>
> Committed: https://crrev.com/f80422e52658fd87d4159bfeeddd703bae1d4180
> Cr-Commit-Position: refs/heads/master@{#391167}

TBR=esprehn@chromium.org,jochen@chromium.org,kinuko@chromium.org,mark@chromium.org,rmcilroy@chromium.org,ulan@chromium.org,hong.zheng@intel.com
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG= 590975 

Review-Url: https://codereview.chromium.org/1953483002
Cr-Commit-Position: refs/heads/master@{#391636}

[modify] https://crrev.com/78980b9332da0264f52bd4ff0b6aeef23cdc21e9/base/memory/memory_pressure_listener.cc
[modify] https://crrev.com/78980b9332da0264f52bd4ff0b6aeef23cdc21e9/base/memory/memory_pressure_listener.h
[modify] https://crrev.com/78980b9332da0264f52bd4ff0b6aeef23cdc21e9/content/renderer/render_thread_impl.cc
[modify] https://crrev.com/78980b9332da0264f52bd4ff0b6aeef23cdc21e9/content/renderer/render_thread_impl.h
[modify] https://crrev.com/78980b9332da0264f52bd4ff0b6aeef23cdc21e9/third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp
[modify] https://crrev.com/78980b9332da0264f52bd4ff0b6aeef23cdc21e9/third_party/WebKit/Source/core/workers/WorkerBackingThread.h
[modify] https://crrev.com/78980b9332da0264f52bd4ff0b6aeef23cdc21e9/third_party/WebKit/Source/web/WebKit.cpp
[modify] https://crrev.com/78980b9332da0264f52bd4ff0b6aeef23cdc21e9/third_party/WebKit/public/web/WebKit.h

Project Member

Comment 19 by bugdroid1@chromium.org, May 11 2016

Comment 20 by u...@chromium.org, Mar 1 2017

hong.zheng@, can we close this issue?
Status: Fixed (was: Available)
Cc: dskiba@chromium.org
What thread RenderThreadImpl::OnSyncMemoryPressure() is supposed to be called on?

On Android it'll be called on Android main thread (where Android delivers memory pressure signals), and not on CrRendererMain.

Is this a problem? I don't see any locks or thread checks in OnSyncMemoryPressure()...

Sign in to add a comment