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

Issue 607077 link

Starred by 9 users

Issue metadata

Status: Assigned
Owner:
Last visit > 30 days ago
Cc:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Feature



Sign in to add a comment

Purge + suspend background tabs to save memory usage

Project Member Reported by hajimehoshi@chromium.org, Apr 27 2016

Issue description

This is a kind of meta bug to record the experiment 'purge + suspend' background tabs.

Background tab purging:
https://docs.google.com/document/d/18YzwARnO7Z3VefRECqlL5_Fuf-ptFy7gY0nNl5eymZM/edit

Purging renderer’s memory as much as possible:
https://docs.google.com/document/d/1thLjq-PYoKWaM_ODDZjojr9VRG6uGnxeL86EaSzYL5k/edit
 
Enable TabManager on Linux
https://codereview.chromium.org/1909903002/
Cc: tasak@google.com bashi@chromium.org
Status: Assigned (was: Untriaged)
Project Member

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

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

commit 6909327ee89d7bd5b69e9e578bcb28388271b2ea
Author: hajimehoshi <hajimehoshi@chromium.org>
Date: Fri May 13 08:30:58 2016

Experimental 'purging and suspending' backgrounded tabs behind the flag

This CL adds an experimental feature, 'purging and suspending'
backgrounded tabs to save memory usage. This feature is behind the
flag '--purge-and-suspend-time' taking a time value in seconds. When
the indicated time passes after a tab goes backgrounded, the
backgrounded tab's memory cache is purged and suspended. We expect
only purgable memory like cache is purged and tab behaviors would never
be affected.

This CL adds only suspending and not purging any cache. I'll add
purging feature later.

BUG=551995, 607077

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

[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/chrome/browser/memory/tab_manager.cc
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/chrome/browser/memory/tab_manager.h
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/chrome/browser/memory/tab_manager_browsertest.cc
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/chrome/common/chrome_switches.cc
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/chrome/common/chrome_switches.h
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/components/scheduler/renderer/renderer_scheduler.h
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/components/scheduler/renderer/renderer_scheduler_impl.cc
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/components/scheduler/renderer/renderer_scheduler_impl.h
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/components/scheduler/renderer/renderer_scheduler_impl_unittest.cc
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/content/browser/renderer_host/render_process_host_impl.cc
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/content/browser/renderer_host/render_process_host_impl.h
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/content/child/child_thread_impl.cc
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/content/child/child_thread_impl.h
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/content/common/child_process_messages.h
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/content/public/browser/render_process_host.h
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/content/public/test/mock_render_process_host.cc
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/content/public/test/mock_render_process_host.h
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/content/renderer/render_thread_impl.cc
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/content/renderer/render_thread_impl.h
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/content/test/fake_renderer_scheduler.cc
[modify] https://crrev.com/6909327ee89d7bd5b69e9e578bcb28388271b2ea/content/test/fake_renderer_scheduler.h

I've implemented more assured suspending: https://codereview.chromium.org/2017763003/

I'll revisit CompressibleString again since 1. we don't have to be careful about unexpected uncompression thanks to suspending a tab, and 2. CompresssibleString would be the most effective to the memory usage compared to other purgeable cache.
Project Member

Comment 6 by bugdroid1@chromium.org, Jun 1 2016

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

commit 384b3b11a1afb71511dc15bc7324f69226ffe801
Author: hajimehoshi <hajimehoshi@chromium.org>
Date: Wed Jun 01 06:21:52 2016

Delegate WebSocket message handlers to the loading task runner

IPC messages including WebSocket messages are dispatched on the default
task runner. We found WebSocket message handlers might call V8
functions. We plan to implement purge + suspend background tabs and need
to suspend all V8 function calls when purge + suspend happens, but the
default task runner can't be suspended since it'd be dangerous. Thus,
this CL delegates WebSocket message handlers from the default task
runner to the loading task runner.

BUG=607077
TEST=n/a

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

[modify] https://crrev.com/384b3b11a1afb71511dc15bc7324f69226ffe801/content/child/child_thread_impl.cc
[modify] https://crrev.com/384b3b11a1afb71511dc15bc7324f69226ffe801/content/child/child_thread_impl.h
[modify] https://crrev.com/384b3b11a1afb71511dc15bc7324f69226ffe801/content/child/websocket_dispatcher.cc
[modify] https://crrev.com/384b3b11a1afb71511dc15bc7324f69226ffe801/content/child/websocket_dispatcher.h
[add] https://crrev.com/384b3b11a1afb71511dc15bc7324f69226ffe801/content/child/websocket_message_filter.cc
[add] https://crrev.com/384b3b11a1afb71511dc15bc7324f69226ffe801/content/child/websocket_message_filter.h
[modify] https://crrev.com/384b3b11a1afb71511dc15bc7324f69226ffe801/content/content_child.gypi
[modify] https://crrev.com/384b3b11a1afb71511dc15bc7324f69226ffe801/content/renderer/render_thread_impl.cc

Project Member

Comment 7 by bugdroid1@chromium.org, Jun 6 2016

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

commit e9897950a1574e0842dc86e0c50e6695773edf41
Author: hajimehoshi <hajimehoshi@chromium.org>
Date: Mon Jun 06 07:36:44 2016

Suspend more task queues for background renderers (experimental)

Backgrounded-tab suspending was introduced at crrev/1914143002, where
only the timer task queue was suspended. We knew this was not enough and
we need to suspend more task queues to prevent the return of purged
cache.

This CL adds the feature to suspend these task queues besides timer task
queues when backgrounded-tab suspending starts:

  * default_loading_tq
  * frame_loading_tq

The above task queues might call V8 functions, which means any purged cache
can be reverted.

This CL doesn't suspend "default_tq" (which we can't suspend since this
conveys critial tasks) and "idle_tq" (which I think is not harmful for
purged caches), "control_(after_wakeup_)tq" (which is only for internal
scheduler housekeeping tasks) and "compositor_tq" (which is not used when
the renderer is backgrounded).

BUG=607077
TEST=n/a

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

[modify] https://crrev.com/e9897950a1574e0842dc86e0c50e6695773edf41/components/scheduler/renderer/renderer_scheduler_impl.cc
[modify] https://crrev.com/e9897950a1574e0842dc86e0c50e6695773edf41/components/scheduler/renderer/renderer_scheduler_impl.h
[modify] https://crrev.com/e9897950a1574e0842dc86e0c50e6695773edf41/components/scheduler/renderer/renderer_scheduler_impl_unittest.cc

I am using "the Great suspender" with chromium and suspending a tab currently doesn't kill all the tab processes, doesn't save any memory, and doesn't kill other tab related processes like Flash plugin processes.

In particular when having lots of tabs "suspended" but only one tab "active" my chromium still uses 2-3Gb of RAM and constantly swaps to disk. 

Would this allow me to _fully_ suspend tabs?

Comment 9 by tkent@chromium.org, Jul 7 2016

Components: -Blink
Issue 498698 has been merged into this issue.
Labels: Hotlist-MPT
Cc: -tasak@google.com hajimehoshi@google.com
Owner: tasak@chromium.org
Project Member

Comment 13 by bugdroid1@chromium.org, Oct 21 2016

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

commit c4f226a843d7af20981be69e545f349de5693eae
Author: hajimehoshi <hajimehoshi@chromium.org>
Date: Fri Oct 21 09:01:57 2016

Bug fix: Use the last hidden time for purge + suspend

|TabStats::last_active| is updated when the tab is made active, and
using this as a base time point for purge + suspend is wrong. Instead,
the time point should be the time when the tab is made hidden.

This CL fixes this by replacing this usage with last_hidden, which is
newly introduced.

BUG=551995, 607077

Review-Url: https://chromiumcodereview.appspot.com/2426733004
Cr-Commit-Position: refs/heads/master@{#426755}

[modify] https://crrev.com/c4f226a843d7af20981be69e545f349de5693eae/chrome/browser/memory/tab_manager.cc
[modify] https://crrev.com/c4f226a843d7af20981be69e545f349de5693eae/chrome/browser/memory/tab_stats.h
[modify] https://crrev.com/c4f226a843d7af20981be69e545f349de5693eae/content/browser/web_contents/web_contents_impl.cc
[modify] https://crrev.com/c4f226a843d7af20981be69e545f349de5693eae/content/browser/web_contents/web_contents_impl.h
[modify] https://crrev.com/c4f226a843d7af20981be69e545f349de5693eae/content/public/browser/web_contents.h

Project Member

Comment 14 by bugdroid1@chromium.org, Nov 22 2016

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

commit 61b4aeba94c28323a9db0b338aa13112759ab47c
Author: tasak <tasak@google.com>
Date: Tue Nov 22 05:09:43 2016

Invoke OnTrimMemoryImmediately when memory state is SUSPENDED

When memory state is changed to be SUSPENDED, invoke v8 GC via OnTrimMemoryImmediately.
It is important to reduce renderer's memory when suspended.

- Purge+Suspend is controlled by base::Feature::kPurgeAndSuspend (c.f. @430225), and is disabled by default.
- intent-to-implement-and-ship of background renderer's purge+suspend is
https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/DK189tnM8l4
- one of the documents attached in the above intent is
 https://docs.google.com/document/d/1EgLimgxWK5DGhptnNVbEGSvVn6Q609ZJaBkLjEPRJvI/edit?usp=sharing

BUG=607077

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

[modify] https://crrev.com/61b4aeba94c28323a9db0b338aa13112759ab47c/content/renderer/render_thread_impl.cc

Project Member

Comment 15 by bugdroid1@chromium.org, Dec 2 2016

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

commit b6edd99c51d17c7a8f058f84acefcc7b935dd893
Author: tasak <tasak@google.com>
Date: Fri Dec 02 04:41:45 2016

Make purge-and-suspend-time finch experiment parameter.

- Replace command_line.HasSwitch with variations::GetVariationParamValue.
- Since Purge+Suspend is now controlled by
base::Feature::kPurgeAndSuspend (c.f. @430225), this change doesn't
enable Purge+Suspend by default.
- intent-to-implement-and-ship of background renderer's purge+suspend is
https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/DK189tnM8l4
- one of the documents attached in the above intent is
 https://docs.google.com/document/d/1EgLimgxWK5DGhptnNVbEGSvVn6Q609ZJaBkLjEPRJvI/edit?usp=sharing

BUG=607077

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

[modify] https://crrev.com/b6edd99c51d17c7a8f058f84acefcc7b935dd893/chrome/browser/memory/tab_manager.cc
[modify] https://crrev.com/b6edd99c51d17c7a8f058f84acefcc7b935dd893/chrome/browser/memory/tab_manager.h
[modify] https://crrev.com/b6edd99c51d17c7a8f058f84acefcc7b935dd893/chrome/common/chrome_switches.cc
[modify] https://crrev.com/b6edd99c51d17c7a8f058f84acefcc7b935dd893/chrome/common/chrome_switches.h

Project Member

Comment 16 by bugdroid1@chromium.org, Dec 16 2016

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

commit 7e65dad367caca32b3b1f9ab7d2233bf11c65549
Author: tasak <tasak@google.com>
Date: Fri Dec 16 10:18:25 2016

Remove is_renderer_suspended_.

Since tab_manager manages whether a renderer is suspended or not, there is no need to keep the state in RenderThreadImpl.

BUG=607077

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

[modify] https://crrev.com/7e65dad367caca32b3b1f9ab7d2233bf11c65549/content/renderer/render_thread_impl.cc
[modify] https://crrev.com/7e65dad367caca32b3b1f9ab7d2233bf11c65549/content/renderer/render_thread_impl.h

Project Member

Comment 17 by bugdroid1@chromium.org, Jan 18 2017

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

commit d224a9dddebc82b819515e4d9c35737c7a92e9d0
Author: tasak <tasak@google.com>
Date: Wed Jan 18 00:44:29 2017

Stop suspending renderer and changing purge interval to 20min

- Since SuspendRenderer sometimes causes very long style recalc and layout (c.f. youtube.com/), disable tab suspension and use default background task throttle.
- also changed time-to-resuspension to 20min. This means, purge background tab's memory every 20min(to be precise 20min+10sec).

- the original document about purge+suspend is
https://docs.google.com/document/d/1EgLimgxWK5DGhptnNVbEGSvVn6Q609ZJaBkLjEPRJvI/edit?usp=sharing
- the difference between the original purge+suspend and purge+suspend with this patch is
https://docs.google.com/document/d/1qIrXsi9BuoAgNu6lVGTcGhbAm2TLPRb_JZ0OhynLjR0/edit?usp=sharing

BUG= 675735 , 607077

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

[modify] https://crrev.com/d224a9dddebc82b819515e4d9c35737c7a92e9d0/chrome/browser/memory/tab_manager.cc
[modify] https://crrev.com/d224a9dddebc82b819515e4d9c35737c7a92e9d0/chrome/browser/memory/tab_manager_unittest.cc
[modify] https://crrev.com/d224a9dddebc82b819515e4d9c35737c7a92e9d0/content/renderer/render_thread_impl.cc
[modify] https://crrev.com/d224a9dddebc82b819515e4d9c35737c7a92e9d0/content/renderer/render_thread_impl.h

Sign in to add a comment