DOM storage databases caches are kept alive after closing tabs |
|||||||
Issue descriptionAfter 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.
,
May 10 2016
More analysis can be found at https://docs.google.com/document/d/162LZ6GPa4EM1AO434B4pvprfjXYLqWYFAi24FjX6Cvk/edit#heading=h.2xkawngl4db5.
,
May 12 2016
,
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
,
May 24 2016
,
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
,
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}
,
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.
,
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.
,
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
,
Aug 29 2016
,
Nov 25 2016
triaging pass: is this fixed?
,
Nov 29 2016
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.
,
Jan 4 2017
|
|||||||
►
Sign in to add a comment |
|||||||
Comment 1 by ssid@chromium.org
, May 10 2016