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

Issue 610551 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Nov 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 466141
issue 593485



Sign in to add a comment

DOM storage databases caches are kept alive after closing tabs

Project Member Reported by ssid@chromium.org, May 10 2016

Issue description

After investigations using memory-infra heap profiling we found that dom storage keeps a large number of databases open even for closed / unused tabs.
Background context:go/memory-infra: memory profiling in chrome://tracing

Now we have a dump provider on dom storage this is easier to reproduce ( bug 605785 ):
Take a memory-infra trace and see "dom_storage" column, or on the sample trace attached.

The situation can be improved by:
1. Reducing the limit on number of databases open for android and low end devices.
2. Purging the caches more aggressively on low end devices.
3. Purge based on the size of cache rather than just number of databases.
4. Add a memory pressure listener to release memory on memory pressure.
 
trace_dom_storage.json.gz
351 KB Download

Comment 1 by ssid@chromium.org, May 10 2016

Cc: primiano@chromium.org michaeln@chromium.org klo...@chromium.org mariakho...@chromium.org
Labels: Memory-Reduction
Project Member

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

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

commit 454f3cefe1b33de5a422778e5cf09d6311bb7fa7
Author: ssid <ssid@chromium.org>
Date: Mon May 23 21:33:48 2016

Purge browser cache for dom storage in a smarter way

This CL does:
1. Use the total cache size to decide when to purge memory from in
   memory caches.
2. Use different limits on databases and cache sizes based on the
   platform and the ram available.
3. For low memory devices do not keep any cache around for closed
   databases (closed tabs).
4. Add a memory pressure listener to dom storage. This listener is
   supposed to construct and destruct in same thread. So, it is
   constructed and destructed on UI thread by DOMStorageContextWrapper
   and post tasks purge to the dom task runner.

BUG= 610551 , 607449 

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

[modify] https://crrev.com/454f3cefe1b33de5a422778e5cf09d6311bb7fa7/content/browser/dom_storage/dom_storage_area.h
[modify] https://crrev.com/454f3cefe1b33de5a422778e5cf09d6311bb7fa7/content/browser/dom_storage/dom_storage_context_impl.cc
[modify] https://crrev.com/454f3cefe1b33de5a422778e5cf09d6311bb7fa7/content/browser/dom_storage/dom_storage_context_impl.h
[modify] https://crrev.com/454f3cefe1b33de5a422778e5cf09d6311bb7fa7/content/browser/dom_storage/dom_storage_context_impl_unittest.cc
[modify] https://crrev.com/454f3cefe1b33de5a422778e5cf09d6311bb7fa7/content/browser/dom_storage/dom_storage_context_wrapper.cc
[modify] https://crrev.com/454f3cefe1b33de5a422778e5cf09d6311bb7fa7/content/browser/dom_storage/dom_storage_context_wrapper.h
[modify] https://crrev.com/454f3cefe1b33de5a422778e5cf09d6311bb7fa7/content/browser/dom_storage/dom_storage_database.cc
[modify] https://crrev.com/454f3cefe1b33de5a422778e5cf09d6311bb7fa7/content/browser/dom_storage/dom_storage_host.cc
[modify] https://crrev.com/454f3cefe1b33de5a422778e5cf09d6311bb7fa7/content/browser/dom_storage/dom_storage_namespace.cc
[modify] https://crrev.com/454f3cefe1b33de5a422778e5cf09d6311bb7fa7/content/browser/dom_storage/dom_storage_namespace.h
[modify] https://crrev.com/454f3cefe1b33de5a422778e5cf09d6311bb7fa7/content/common/dom_storage/dom_storage_types.h
[modify] https://crrev.com/454f3cefe1b33de5a422778e5cf09d6311bb7fa7/tools/metrics/histograms/histograms.xml

Comment 5 by ssid@chromium.org, May 24 2016

Owner: ssid@chromium.org
Project Member

Comment 6 by bugdroid1@chromium.org, May 25 2016

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

commit bfc745d81e242821f10aa3eaece65ab70f685725
Author: ssid <ssid@chromium.org>
Date: Wed May 25 21:30:39 2016

Fix purging logic for dom_storage caches

Do not try purging the caches when no unopened database was found.

BUG= 610551 

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

[modify] https://crrev.com/bfc745d81e242821f10aa3eaece65ab70f685725/content/browser/dom_storage/dom_storage_context_impl.cc

Comment 7 by ssid@chromium.org, Jun 21 2016

Committed: https://crrev.com/cc032854d31ede369b1cfb2090ea3abf55538630

Add tagged histogram with reasons of purging the dom storage databases

The existing metric shows us useful information on how much cache is
purged. But, we do not know about the reason for purging. Since there a
lot of cases where we are purging less than 10KB, it would be better to
understand this case and try to avoid triggering purge code.

BUG= 610551 
Review-Url: https://codereview.chromium.org/2073523003
Cr-Commit-Position: refs/heads/master@{#400847}

Comment 8 by ssid@chromium.org, Jun 24 2016

Looking at the histograms:
Aggregated by unique users:
http://shortn/_FIVJcX0sne

Not aggregated by users:
http://shortn/_EUfitt1Kf4

It feels like the major reasons for 0Kib purges are that we try to keep purging even when there are no databases open, espcially in cases of memory pressure signals which gets triggered repeatedly for the users.
So, the first histogram shows far less 0s because atthe first signal for each user, we actually purge some memory and 0s after the first try.

Comment 9 by ssid@chromium.org, Jun 24 2016

Also, I think it is expected that we continue to show 0s in some cases even after fixing the above issue because there are lots of databases that are of 0 size opened by webpages: http://shortn/_DWaI0sqx60. This still clears some memory used by the objects / metadata but that is not shown by the histograms.
Project Member

Comment 10 by bugdroid1@chromium.org, Jun 28 2016

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

commit d000d7c16219b88a225ef7676ab58f3388691623
Author: ssid <ssid@chromium.org>
Date: Tue Jun 28 20:41:19 2016

[DOMStorage] Do not try purging caches when no database is open

Looking at the histogram metrics, it looks like there are multiple
memory pressure signals triggered in the same device frequently. We
still record multiple 0s after clearing the caches at the first signal.
This CL tries to reduce this by checking before calling purge and
recording the values.

BUG= 610551 

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

[modify] https://crrev.com/d000d7c16219b88a225ef7676ab58f3388691623/content/browser/dom_storage/dom_storage_context_impl.cc

Comment 11 by ssid@chromium.org, Aug 29 2016

Blocking: 466141
Labels: -Pri-2 Pri-3
Status: Started (was: Untriaged)
triaging pass: is this fixed?

Comment 13 by ssid@chromium.org, Nov 29 2016

Status: Fixed (was: Started)
Yes I think we are doing what we can to optimize the usage for inactive databases. The usage could still be high because of bad webpages and this cannot be avoided. For more optimization ideas like compression, we should have new bugs.
Components: Internals>Instrumentation>Memory

Sign in to add a comment