Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Issue 875503003: Allow Oilpan heap objects account for their external allocations. (Closed)

Created:
5 years, 10 months ago by sof
Modified:
5 years, 10 months ago
CC:
blink-reviews, oilpan-reviews, kouhei+heap_chromium.org, Mads Ager (chromium)
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Target Ref:
refs/heads/master
Project:
blink
Visibility:
Public.

Description

Allow Oilpan heap objects account for their external allocations. The GC heuristics take into account the amount of objects allocated since the last GC, in terms of the amount of Oilpan heap bytes allocated. It does not consider the amount of external memory owned by an Oilpan object. Allow objects to register such external allocations and have the GC heuristics consider it -- if the heap isn't otherwise considered worth GCing but it contains references to a large amount of external memory, scheduling a GC may lessen the overall memory pressure for the process. Along with this, also add support for letting the outside world notify Oilpan that a GC is now really worth considering. Intended used by other allocators if they are running into near-OOM conditions. R=haraken BUG=456498 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=190702

Patch Set 1 #

Patch Set 2 : improvements; have external allocations trigger a conservative GC #

Patch Set 3 : Have reporting of external allocations check if a GC is now reqd #

Patch Set 4 : bail out early if urgent-gc has been set #

Patch Set 5 : Have conservative GC take prio over scheduled GC when urgent GCing #

Total comments: 10

Patch Set 6 : Sweep after urgent GC + minor updates #

Patch Set 7 : Adjust urgent GC limits + rebase #

Total comments: 20

Patch Set 8 : Inline increaseExternallyAllocatedBytes() #

Total comments: 10

Patch Set 9 : minor optimizations and tuning #

Total comments: 2

Patch Set 10 : minor tidying #

Total comments: 2

Patch Set 11 : more minor stuff #

Unified diffs Side-by-side diffs Delta from patch set Stats (+133 lines, -9 lines) Patch
M Source/core/dom/Text.h View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -0 lines 0 comments Download
M Source/core/dom/Text.cpp View 1 2 3 4 5 6 7 8 9 2 chunks +43 lines, -0 lines 0 comments Download
M Source/platform/heap/Heap.h View 1 2 3 4 5 6 7 8 9 4 chunks +45 lines, -2 lines 0 comments Download
M Source/platform/heap/Heap.cpp View 1 2 3 4 5 6 7 8 3 chunks +31 lines, -2 lines 0 comments Download
M Source/platform/heap/ThreadState.cpp View 1 2 3 4 5 6 7 8 9 10 2 chunks +12 lines, -5 lines 0 comments Download

Messages

Total messages: 56 (8 generated)
sof
fyi. With Text nodes instrumented to account for the length of their externally-allocated strings (provided ...
5 years, 10 months ago (2015-02-09 13:02:22 UTC) #2
haraken
Thanks for the patch! I think this is going a right way though. > As ...
5 years, 10 months ago (2015-02-09 13:59:34 UTC) #3
sof
On 2015/02/09 13:59:34, haraken wrote: > Thanks for the patch! I think this is going ...
5 years, 10 months ago (2015-02-09 15:52:49 UTC) #4
sof
On 2015/02/09 15:52:49, sof wrote: > On 2015/02/09 13:59:34, haraken wrote: > > Thanks for ...
5 years, 10 months ago (2015-02-09 22:48:37 UTC) #5
haraken
https://codereview.chromium.org/875503003/diff/80001/Source/core/dom/Text.cpp File Source/core/dom/Text.cpp (right): https://codereview.chromium.org/875503003/diff/80001/Source/core/dom/Text.cpp#newcode50 Source/core/dom/Text.cpp:50: Heap::increaseExternallyAllocatedBytes(length); Would it be possible to use these memory ...
5 years, 10 months ago (2015-02-10 01:23:17 UTC) #7
haraken
kouhei-san: Do you have any thoughts on how Oilpan should interact with PartiitonAlloc?
5 years, 10 months ago (2015-02-11 00:55:20 UTC) #9
sof
https://codereview.chromium.org/875503003/diff/80001/Source/core/dom/Text.cpp File Source/core/dom/Text.cpp (right): https://codereview.chromium.org/875503003/diff/80001/Source/core/dom/Text.cpp#newcode50 Source/core/dom/Text.cpp:50: Heap::increaseExternallyAllocatedBytes(length); On 2015/02/10 01:23:17, haraken wrote: > > Would ...
5 years, 10 months ago (2015-02-11 15:58:25 UTC) #10
haraken
Discussed this in Tokyo as well. Another (probably simpler) idea might be as follows: ThreadState::postGCProcessing() ...
5 years, 10 months ago (2015-02-12 01:44:52 UTC) #11
kouhei (in TOK)
Both sof@'s idea and haraken@'s idea sgtm, however I'd prefer to try out the haraken@'s ...
5 years, 10 months ago (2015-02-12 01:47:09 UTC) #12
sof
On 2015/02/12 01:44:52, haraken wrote: > Discussed this in Tokyo as well. > > Another ...
5 years, 10 months ago (2015-02-12 07:23:56 UTC) #13
sof
https://codereview.chromium.org/875503003/diff/80001/Source/core/loader/ImageLoader.cpp File Source/core/loader/ImageLoader.cpp (right): https://codereview.chromium.org/875503003/diff/80001/Source/core/loader/ImageLoader.cpp#newcode242 Source/core/loader/ImageLoader.cpp:242: RefPtrWillBeRawPtr<Element> protectElement(m_element.get()); On 2015/02/11 15:58:25, sof wrote: > On ...
5 years, 10 months ago (2015-02-12 07:28:31 UTC) #14
sof
On 2015/02/12 07:28:31, sof wrote: > https://codereview.chromium.org/875503003/diff/80001/Source/core/loader/ImageLoader.cpp > File Source/core/loader/ImageLoader.cpp (right): > > https://codereview.chromium.org/875503003/diff/80001/Source/core/loader/ImageLoader.cpp#newcode242 > ...
5 years, 10 months ago (2015-02-12 17:25:02 UTC) #15
kouhei (in TOK)
On 2015/02/12 07:23:56, sof wrote: > On 2015/02/12 01:44:52, haraken wrote: > > Discussed this ...
5 years, 10 months ago (2015-02-13 00:30:09 UTC) #16
haraken
On 2015/02/13 00:30:09, kouhei wrote: > On 2015/02/12 07:23:56, sof wrote: > > On 2015/02/12 ...
5 years, 10 months ago (2015-02-13 01:47:10 UTC) #17
sof
On 2015/02/13 00:30:09, kouhei wrote: > On 2015/02/12 07:23:56, sof wrote: > > On 2015/02/12 ...
5 years, 10 months ago (2015-02-13 06:44:16 UTC) #18
haraken
On 2015/02/13 06:44:16, sof wrote: > On 2015/02/13 00:30:09, kouhei wrote: > > On 2015/02/12 ...
5 years, 10 months ago (2015-02-13 09:25:58 UTC) #19
haraken
Any update on this one?
5 years, 10 months ago (2015-02-18 04:42:22 UTC) #20
sof
On 2015/02/18 04:42:22, haraken wrote: > Any update on this one? Not really, the above ...
5 years, 10 months ago (2015-02-18 07:38:08 UTC) #21
haraken
On 2015/02/18 07:38:08, sof wrote: > On 2015/02/18 04:42:22, haraken wrote: > > Any update ...
5 years, 10 months ago (2015-02-18 08:12:54 UTC) #22
sof
On 2015/02/18 08:12:54, haraken wrote: > On 2015/02/18 07:38:08, sof wrote: > > On 2015/02/18 ...
5 years, 10 months ago (2015-02-18 08:54:18 UTC) #23
haraken
On 2015/02/18 08:54:18, sof wrote: > On 2015/02/18 08:12:54, haraken wrote: > > On 2015/02/18 ...
5 years, 10 months ago (2015-02-18 14:46:36 UTC) #24
haraken
On 2015/02/18 14:46:36, haraken wrote: > On 2015/02/18 08:54:18, sof wrote: > > On 2015/02/18 ...
5 years, 10 months ago (2015-02-18 15:02:38 UTC) #25
sof
On 2015/02/18 15:02:38, haraken wrote: > On 2015/02/18 14:46:36, haraken wrote: > > On 2015/02/18 ...
5 years, 10 months ago (2015-02-18 15:47:38 UTC) #26
haraken
On 2015/02/18 15:47:38, sof wrote: > On 2015/02/18 15:02:38, haraken wrote: > > On 2015/02/18 ...
5 years, 10 months ago (2015-02-18 15:55:17 UTC) #27
sof
On 2015/02/18 15:55:17, haraken wrote: > On 2015/02/18 15:47:38, sof wrote: > > On 2015/02/18 ...
5 years, 10 months ago (2015-02-19 13:11:19 UTC) #28
haraken
On 2015/02/19 13:11:19, sof wrote: > On 2015/02/18 15:55:17, haraken wrote: > > On 2015/02/18 ...
5 years, 10 months ago (2015-02-19 16:21:30 UTC) #29
haraken
Mostly looks good! https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.cpp File Source/core/dom/Text.cpp (right): https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.cpp#newcode47 Source/core/dom/Text.cpp:47: // If the external string kept ...
5 years, 10 months ago (2015-02-19 23:47:44 UTC) #30
haraken
On 2015/02/19 23:47:44, haraken wrote: > Mostly looks good! > > https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.cpp > File Source/core/dom/Text.cpp ...
5 years, 10 months ago (2015-02-19 23:55:38 UTC) #31
sof
https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.cpp File Source/core/dom/Text.cpp (right): https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.cpp#newcode63 Source/core/dom/Text.cpp:63: if (length > stringLengthThreshold) { On 2015/02/19 23:47:43, haraken ...
5 years, 10 months ago (2015-02-20 09:33:49 UTC) #32
haraken
(Will take a final look at this today.)
5 years, 10 months ago (2015-02-23 04:11:27 UTC) #33
haraken
Here is the final round of comments. https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.cpp File Source/core/dom/Text.cpp (right): https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.cpp#newcode63 Source/core/dom/Text.cpp:63: if (length ...
5 years, 10 months ago (2015-02-23 08:42:27 UTC) #34
sof
https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.cpp File Source/core/dom/Text.cpp (right): https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.cpp#newcode63 Source/core/dom/Text.cpp:63: if (length > stringLengthThreshold) { On 2015/02/23 08:42:27, haraken ...
5 years, 10 months ago (2015-02-23 09:13:37 UTC) #35
haraken
https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.cpp File Source/core/dom/Text.cpp (right): https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.cpp#newcode63 Source/core/dom/Text.cpp:63: if (length > stringLengthThreshold) { On 2015/02/23 09:13:37, sof ...
5 years, 10 months ago (2015-02-23 09:26:34 UTC) #36
sof
On 2015/02/23 09:26:34, haraken wrote: > https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.cpp > File Source/core/dom/Text.cpp (right): > > https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.cpp#newcode63 > ...
5 years, 10 months ago (2015-02-23 12:24:39 UTC) #37
sof
https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.h File Source/core/dom/Text.h (right): https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.h#newcode64 Source/core/dom/Text.h:64: #if ENABLE(OILPAN) On 2015/02/23 08:42:27, haraken wrote: > On ...
5 years, 10 months ago (2015-02-23 12:26:14 UTC) #38
haraken
LGTM https://codereview.chromium.org/875503003/diff/140001/Source/platform/heap/ThreadState.cpp File Source/platform/heap/ThreadState.cpp (right): https://codereview.chromium.org/875503003/diff/140001/Source/platform/heap/ThreadState.cpp#newcode701 Source/platform/heap/ThreadState.cpp:701: if (!Heap::isUrgentGCRequested() || !isSweepingScheduled()) On 2015/02/23 12:26:13, sof ...
5 years, 10 months ago (2015-02-23 14:59:08 UTC) #39
sof
https://codereview.chromium.org/875503003/diff/140001/Source/platform/heap/ThreadState.cpp File Source/platform/heap/ThreadState.cpp (right): https://codereview.chromium.org/875503003/diff/140001/Source/platform/heap/ThreadState.cpp#newcode701 Source/platform/heap/ThreadState.cpp:701: if (!Heap::isUrgentGCRequested() || !isSweepingScheduled()) On 2015/02/23 14:59:07, haraken wrote: ...
5 years, 10 months ago (2015-02-23 15:03:40 UTC) #40
haraken
https://codereview.chromium.org/875503003/diff/140001/Source/platform/heap/ThreadState.cpp File Source/platform/heap/ThreadState.cpp (right): https://codereview.chromium.org/875503003/diff/140001/Source/platform/heap/ThreadState.cpp#newcode701 Source/platform/heap/ThreadState.cpp:701: if (!Heap::isUrgentGCRequested() || !isSweepingScheduled()) On 2015/02/23 15:03:40, sof wrote: ...
5 years, 10 months ago (2015-02-23 15:06:22 UTC) #41
sof
https://codereview.chromium.org/875503003/diff/140001/Source/platform/heap/ThreadState.cpp File Source/platform/heap/ThreadState.cpp (right): https://codereview.chromium.org/875503003/diff/140001/Source/platform/heap/ThreadState.cpp#newcode701 Source/platform/heap/ThreadState.cpp:701: if (!Heap::isUrgentGCRequested() || !isSweepingScheduled()) On 2015/02/23 15:06:22, haraken wrote: ...
5 years, 10 months ago (2015-02-23 15:22:40 UTC) #42
sof
https://codereview.chromium.org/875503003/diff/160001/Source/core/dom/Text.cpp File Source/core/dom/Text.cpp (right): https://codereview.chromium.org/875503003/diff/160001/Source/core/dom/Text.cpp#newcode61 Source/core/dom/Text.cpp:61: void registerExternalAllocation(size_t length, RegistrationMode mode) On 2015/02/23 14:59:08, haraken ...
5 years, 10 months ago (2015-02-23 15:56:07 UTC) #44
haraken
https://codereview.chromium.org/875503003/diff/180001/Source/platform/heap/ThreadState.cpp File Source/platform/heap/ThreadState.cpp (right): https://codereview.chromium.org/875503003/diff/180001/Source/platform/heap/ThreadState.cpp#newcode705 Source/platform/heap/ThreadState.cpp:705: if (!Heap::isUrgentGCRequested() || !isSweepingScheduled()) Sorry to bug you a ...
5 years, 10 months ago (2015-02-23 16:40:29 UTC) #45
sof
Confirmed in a local Windows build that the latest PS cures the perf test OOMs; ...
5 years, 10 months ago (2015-02-23 20:47:05 UTC) #46
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/875503003/200001
5 years, 10 months ago (2015-02-23 20:47:21 UTC) #49
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/875503003/200001
5 years, 10 months ago (2015-02-23 20:59:27 UTC) #52
haraken
LGTM
5 years, 10 months ago (2015-02-23 23:45:01 UTC) #53
commit-bot: I haz the power
Committed patchset #11 (id:200001) as https://src.chromium.org/viewvc/blink?view=rev&revision=190702
5 years, 10 months ago (2015-02-24 00:33:55 UTC) #54
sof
On 2015/02/19 23:55:38, haraken wrote: > On 2015/02/19 23:47:44, haraken wrote: > > Mostly looks ...
5 years, 10 months ago (2015-02-25 09:56:53 UTC) #55
haraken
5 years, 10 months ago (2015-02-25 10:04:49 UTC) #56
Message was sent while issue was closed.
On 2015/02/25 09:56:53, sof wrote:
> On 2015/02/19 23:55:38, haraken wrote:
> > On 2015/02/19 23:47:44, haraken wrote:
> > > Mostly looks good!
> > > 
> > >
> https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.cpp
> > > File Source/core/dom/Text.cpp (right):
> > > 
> > >
> >
>
https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.cp...
> > > Source/core/dom/Text.cpp:47: // If the external string kept by a Text node
> > > exceed this threshold length,
> > > 
> > > exceeds
> > > 
> > >
> >
>
https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.cp...
> > > Source/core/dom/Text.cpp:63: if (length > stringLengthThreshold) {
> > > 
> > > Does it really make sense to have the threshold?
> > > 
> > > Previously we were using a similar threshold to report memory used by
> NodeList
> > > to V8. However, it turned out that it can end up mis-estimating the amount
> of
> > > memory used by NodeLists and it actually caused OOM (when a ton of
NodeLists
> > > each of which is smaller than the threshold are allocated). So we
eliminated
> > the
> > > threshold from the NodeList.
> > > 
> > >
https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.h
> > > File Source/core/dom/Text.h (right):
> > > 
> > >
> >
>
https://codereview.chromium.org/875503003/diff/120001/Source/core/dom/Text.h#...
> > > Source/core/dom/Text.h:64: #if ENABLE(OILPAN)
> > > 
> > > You can remove ENABLE(OILPAN). We normally add ENABLE(OILPAN) to the
> contents
> > of
> > > a trace method.
> > > 
> > >
> >
>
https://codereview.chromium.org/875503003/diff/120001/Source/platform/heap/He...
> > > File Source/platform/heap/Heap.cpp (right):
> > > 
> > >
> >
>
https://codereview.chromium.org/875503003/diff/120001/Source/platform/heap/He...
> > > Source/platform/heap/Heap.cpp:2833: atomicAdd(&s_externallyAllocatedBytes,
> > > static_cast<long>(delta));
> > > 
> > > You can use the return value of atomicAdd, instead of looking up
> > > externallyAllocatedBytes in 2846 again.
> > > 
> > > Then you can write:
> > > 
> > >   size_t externalBytesSinceGC = atomicAdd(&s_externallyAllocatedBytes,
> > > static_cast<long>(delta));
> > >   if (LIKELY(externalBytesSinceGC < 100 * 1024 * 1024))
> > >     return;
> > > 
> > > and thus reduce the cost of this method (I think
> > > Heap::increaseExternallyAllocatedBytes must be light-weight). You can
inline
> > > this part if necessary.
> > > 
> > >
> >
>
https://codereview.chromium.org/875503003/diff/120001/Source/platform/heap/He...
> > > Source/platform/heap/Heap.cpp:2846: size_t externalBytesSinceGC =
> > > externallyAllocatedBytes();
> > > 
> > > externalBytesSinceLastGC
> > > 
> > >
> >
>
https://codereview.chromium.org/875503003/diff/120001/Source/platform/heap/He...
> > > File Source/platform/heap/Heap.h (right):
> > > 
> > >
> >
>
https://codereview.chromium.org/875503003/diff/120001/Source/platform/heap/He...
> > > Source/platform/heap/Heap.h:1010: static bool isGCUrgentlyRequested() {
> return
> > > acquireLoad(&s_requestedUrgentGC); }
> > > 
> > > isUrgentGCRequested ?
> > > 
> > >
> >
>
https://codereview.chromium.org/875503003/diff/120001/Source/platform/heap/Th...
> > > File Source/platform/heap/ThreadState.cpp (right):
> > > 
> > >
> >
>
https://codereview.chromium.org/875503003/diff/120001/Source/platform/heap/Th...
> > > Source/platform/heap/ThreadState.cpp:701: if
(!Heap::isGCUrgentlyRequested()
> > ||
> > > !isSweepingScheduled())
> > > 
> > > As commented earlier, I guess we should just call completeSweep() if an
> urgent
> > > GC is scheduled.
> > > 
> > > Note that scheduleGCIfNeeded can be called by outOfLineAllocate, where
it's
> > not
> > > guaranteed that sweeping is complete.
> > > 
> > > So I still think that something like:
> > > 
> > > >   if (Heap::isGCUrgentlyRequested())
> > > >     completeSweep();
> > > >   if (isSweepingInProgress())
> > > >     return;
> > > 
> > > is what we want.
> > > 
> > >
> >
>
https://codereview.chromium.org/875503003/diff/120001/Source/platform/heap/Th...
> > > Source/platform/heap/ThreadState.cpp:708: if (shouldForceConservativeGC())
{
> > > 
> > > Slightly better:
> > > 
> > > if (Heap::isGCUrgentlyRequested()) {
> > >   completeSweep();
> > >   Heap::clearUrgentGC();
> > >   Heap::collectGarbage(HeapPointersOnStack, GCWithSweep);
> > >   return;
> > > }
> > > if (shouldForceConservativeGC()) {
> > >   Heap::collectGarbage(ThreadState::HeapPointersOnStack,
> > > ThreadState::GCWithoutSweep);
> > > } else if (shouldSchedulePreciseGC())
> > >   ...
> > 
> > BTW, I'm curious how V8 is aware of the string memory allocated by
> > Text::create(). In other words, I'm curious why dom-modify.html is not
causing
> > OOM in non-oilpan.
> 
> If you look at textarea-dom.html, it creates Text nodes in
> replaceChildrenWithText() that have a ref-count of 1.
> 
> As the loop runs, each of these will be replaced & finalized promptly,
> preventing a heap build up of Text nodes (with ever greater strings attached.)

ah, V8 minor GCs drop the persistent handles to the Text Nodes, which promptly
collects the strings... Makes sense :)

Powered by Google App Engine
This is Rietveld 408576698