Closed
Bug 927740
Opened 12 years ago
Closed 12 years ago
Fix up all the memory management observations
Categories
(Toolkit :: about:memory, defect)
Toolkit
about:memory
Tracking
()
RESOLVED
FIXED
mozilla28
Tracking | Status | |
---|---|---|
firefox28 | --- | fixed |
People
(Reporter: n.nethercote, Assigned: n.nethercote)
Details
(Whiteboard: [MemShrink:P2][qa-])
Attachments
(4 files, 1 obsolete file)
1.41 KB,
patch
|
khuey
:
review+
|
Details | Diff | Splinter Review |
4.55 KB,
patch
|
khuey
:
review+
|
Details | Diff | Splinter Review |
9.47 KB,
patch
|
khuey
:
review+
|
Details | Diff | Splinter Review |
888 bytes,
patch
|
khuey
:
review+
|
Details | Diff | Splinter Review |
In about:memory, the "GC" button triggers GC in the current process and the child processes. Likewise for the "CC" button. But the "Minimize memory usage" button only does stuff in the current process.
![]() |
Assignee | |
Updated•12 years ago
|
Whiteboard: [MemShrink] → [MemShrink:P2]
![]() |
Assignee | |
Comment 1•12 years ago
|
||
Turns out we already have the machinery in place for sending MMU requests to
children (i.e SendMinimizeMemoryUsage() and RecvMinimizeMemoryUsage()). So I
just had to hook up an observer.
Attachment #832908 -
Flags: review?(continuation)
Comment 2•12 years ago
|
||
Comment on attachment 832908 [details] [diff] [review]
Make about:memory's "Minimize Memory Usage" button affect child processes, like the "GC" and "CC" buttons.
Looks fine to me, but I don't understand all the machinery here, so I'm going to pass the buck. For instance, why is there stuff in RuntimeService for child-gc-request but not child-cc-request?
http://mxr.mozilla.org/mozilla-central/ident?i=GC_REQUEST_OBSERVER_TOPIC
Attachment #832908 -
Flags: review?(continuation) → review?(khuey)
![]() |
Assignee | |
Comment 3•12 years ago
|
||
> why is there stuff in RuntimeService
> for child-gc-request but not child-cc-request?
Interesting question. It looks like workers won't get CC'd when a CC is requested.
There are some other inconsistencies in this stuff, e.g. when a child gets a CC request it actually does GC+CC.
But these are both orthogonal to this patch, and make sense to do as follow-up patches.
Comment 4•12 years ago
|
||
Sure, my point was just that I wasn't sure what your patch needed, as it doesn't have the "extra child-gc-request stuff" as far as I could see.
![]() |
Assignee | |
Comment 5•12 years ago
|
||
Hmm, it's an interesting question if nsMemoryReporterManager::MinimizeMemoryUsage() should just work with the current process or with all child processes too. My patch does the latter, but I could instead leave it as is and instead send the "minimize-memory-pressure" event from aboutMemory.js, as is done for the GC and CC events.
![]() |
Assignee | |
Updated•12 years ago
|
Attachment #832908 -
Flags: review?(khuey)
![]() |
Assignee | |
Comment 6•12 years ago
|
||
I'm broadening this bug's scope to cover all the inconsistencies in how these things are handled.
Summary: "Minimize memory usage" doesn't do anything with child processes → Fix up all the memory management observations
![]() |
Assignee | |
Comment 7•12 years ago
|
||
Here's what happens with the three about:memory buttons. Problems are numbered.
"GC" button:
- parent process calls GCForReason() on the main JSRuntime
- triggers "child-gc-request"
- RuntimeService observes it, and all workers (parent and child) call
GCForReason (via GarbageCollectRunnable)
- ContentParent observes it; each child process is triggered and calls
GarbageCollectNow() on main JSRuntime
- nothing happens with child process workers [1]
"CC" button:
- parent process CycleCollectNow() on the main JSRuntime
- triggers "child-cc-request"
- RuntimeService doesn't observe it [2]
- ContentParent observes it; each child process is triggered and calls
GarbageCollectNow() *and* CycleCollectNow() [3] on the main runtime
- nothing happens with child process workers [4]
"MMU" button:
- triggers three "memory-pressure" events and a "after-minimize-memory-usage"
event
- nsJSEnvironmentObserver observes it, and calls
GarbageCollectNow(ShrinkingGC) and CycleCollectNow()
- RuntimeService observes it, and all workers (parent and child) call
ShrinkingGC(), but no CC [5]
- ContentParent doesn't observe it [6] -- nothing done with child processes
Here's how I think we can fix the problems.
- rebroadcast "child-{gc,cc}-request" and "child-cc-request" in child
processes, so workers will GC/CC [1] [4]
- make RuntimeService observe "child-cc-request" [2]
- make "child-cc-request" only trigger CC, not GC, in child processes [3]
- make RuntimeService do CC on "memory-pressure" [5]
- add "child-mmu-request", broadcast it on "MMU" button press, and then
make it trigger MinimizeMemoryUsage() in child processes accordingly [6]
![]() |
Assignee | |
Comment 8•12 years ago
|
||
This patch fixes problems [1], [4] and [3]. Actually, [1] and [4] seem to be
non-problems currently, because child processes don't appear to use workers?
It still seems worth rebroadcasting the notifications in case that changes in
the future.
Attachment #8335106 -
Flags: review?(khuey)
![]() |
Assignee | |
Comment 9•12 years ago
|
||
This patch fixes problem [6].
Note that child-mmu-request is only observed by child processes, whereas
child-{gc,cc}-request is observed by child processes and workers in the parent
process. (Workers instead observe the memory-pressure events that
MinimizeMemoryUsage() triggers.)
So I wonder if we should rename them as "child-and-worker-{gc,cc}-request" to
clarify things.
Attachment #8335108 -
Flags: review?(khuey)
![]() |
Assignee | |
Updated•12 years ago
|
Attachment #832908 -
Attachment is obsolete: true
![]() |
Assignee | |
Comment 10•12 years ago
|
||
This patch fixes problem [2].
The dummy arg to CycleCollect() sucks, but I can't see how to modify
BROADCAST_ALL_WORKERS to handle zero-arg functions.
It'd be nice to have tests for all this stuff, but I don't know how they would
work.
Attachment #8335109 -
Flags: review?(khuey)
![]() |
Assignee | |
Comment 11•12 years ago
|
||
This patch fixes problem [5].
Attachment #8335110 -
Flags: review?(khuey)
Comment on attachment 8335109 [details] [diff] [review]
(part 3) - Make workers respond to "child-cc-request" notifications.
Review of attachment 8335109 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/workers/RuntimeService.cpp
@@ +2215,5 @@
> Cleanup();
> return NS_OK;
> }
> if (!strcmp(aTopic, GC_REQUEST_OBSERVER_TOPIC)) {
> + GarbageCollectAllWorkers(/* shrinking = */ false);
njn++
Attachment #8335109 -
Flags: review?(khuey) → review+
Attachment #8335110 -
Flags: review?(khuey) → review+
Comment on attachment 8335106 [details] [diff] [review]
(part 1) - Fix observation of GC and CC requests by child processes.
Review of attachment 8335106 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/ipc/ContentChild.cpp
@@ -1284,5 @@
>
> bool
> ContentChild::RecvCycleCollect()
> {
> - nsJSContext::GarbageCollectNow(JS::gcreason::DOM_IPC);
Why did you remove this?
Attachment #8335108 -
Flags: review?(khuey) → review+
![]() |
Assignee | |
Comment 14•12 years ago
|
||
> > bool
> > ContentChild::RecvCycleCollect()
> > {
> > - nsJSContext::GarbageCollectNow(JS::gcreason::DOM_IPC);
>
> Why did you remove this?
That's problem [3] -- prior to my patch, everywhere else the "CC" button just triggers cycle collection, but in the child it triggers GC as well.
Attachment #8335106 -
Flags: review?(khuey) → review+
![]() |
Assignee | |
Comment 15•12 years ago
|
||
On memory pressure, should workers CC after GC?
![]() |
Assignee | |
Comment 16•12 years ago
|
||
> On memory pressure, should workers CC after GC?
Oh, that's what patch 4 does. Never mind.
![]() |
Assignee | |
Comment 17•12 years ago
|
||
Comment 18•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/24e2453b9e53
https://hg.mozilla.org/mozilla-central/rev/14a0fe515c9c
https://hg.mozilla.org/mozilla-central/rev/4eea4558dff5
https://hg.mozilla.org/mozilla-central/rev/03171880d9f4
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla28
status-firefox28:
--- → fixed
Whiteboard: [MemShrink:P2] → [MemShrink:P2][qa-]
You need to log in
before you can comment on or make changes to this bug.
Description
•