зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1335148 - Part 2: Introduce notification for end of memory pressure. r=gsvelto,snorp
For Fennec on Android, if we haven't received memory pressure notifications from the OS for a certain amount of time (in the order of ~15 mins), we assume that we're no longer under memory pressure. In order to turn the bfcache back on when that happens, we now want to be able to forward this fact to Gecko as well. Unfortunately, the way memory pressure is tracked using an atomic variable doesn't easily allow to fully extend the existing priority rules between "new" and "ongoing" to include a new "stopping of memory pressure" event. Since we're not using Dispatch*Eventual*MemoryPressure on Android and therefore the queuing priority behaviour isn't actually relevant for us, we just ignore that and only enforce that a pending "new" memory pressure event takes priority over a "stop" event. MozReview-Commit-ID: 90C9KogUyvf --HG-- extra : rebase_source : 4e71a31433557d8d486f941953717a88d5d87e7d
This commit is contained in:
Родитель
29713de206
Коммит
991ff633f3
|
@ -27,9 +27,9 @@ void
|
|||
NS_DispatchEventualMemoryPressure(MemoryPressureState aState)
|
||||
{
|
||||
/*
|
||||
* A new memory pressure event erases an ongoing memory pressure, but an
|
||||
* existing "new" memory pressure event takes precedence over a new "ongoing"
|
||||
* memory pressure event.
|
||||
* A new memory pressure event erases an ongoing (or stop of) memory pressure,
|
||||
* but an existing "new" memory pressure event takes precedence over a new
|
||||
* "ongoing" or "stop" memory pressure event.
|
||||
*/
|
||||
switch (aState) {
|
||||
case MemPressure_None:
|
||||
|
@ -39,8 +39,9 @@ NS_DispatchEventualMemoryPressure(MemoryPressureState aState)
|
|||
sMemoryPressurePending = MemPressure_New;
|
||||
break;
|
||||
case MemPressure_Ongoing:
|
||||
case MemPressure_Stopping:
|
||||
sMemoryPressurePending.compareExchange(MemPressure_None,
|
||||
MemPressure_Ongoing);
|
||||
aState);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,18 @@ enum MemoryPressureState
|
|||
* possible on the clean-up of the memory. After all, we are trying to
|
||||
* keep Gecko alive as long as possible.
|
||||
*/
|
||||
MemPressure_Ongoing
|
||||
MemPressure_Ongoing,
|
||||
|
||||
/*
|
||||
* Memory pressure stopped.
|
||||
*
|
||||
* We're no longer under acute memory pressure, so we might want to have a
|
||||
* chance of (cautiously) re-enabling some things we previously turned off.
|
||||
* As above, an already enqueued new memory pressure event takes precedence.
|
||||
* The priority ordering between concurrent attempts to queue both stopped
|
||||
* and ongoing memory pressure is currently not defined.
|
||||
*/
|
||||
MemPressure_Stopping
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1268,11 +1268,15 @@ nsThread::DoMainThreadSpecificProcessing(bool aReallyWait)
|
|||
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||
|
||||
if (os) {
|
||||
// Use no-forward to prevent the notifications from being transferred to
|
||||
// the children of this process.
|
||||
os->NotifyObservers(nullptr, "memory-pressure",
|
||||
mpPending == MemPressure_New ? u"low-memory-no-forward" :
|
||||
u"low-memory-ongoing-no-forward");
|
||||
if (mpPending == MemPressure_Stopping) {
|
||||
os->NotifyObservers(nullptr, "memory-pressure-stop", nullptr);
|
||||
} else {
|
||||
// Use no-forward to prevent the notifications from being transferred to
|
||||
// the children of this process.
|
||||
os->NotifyObservers(nullptr, "memory-pressure",
|
||||
mpPending == MemPressure_New ? u"low-memory-no-forward" :
|
||||
u"low-memory-ongoing-no-forward");
|
||||
}
|
||||
} else {
|
||||
NS_WARNING("Can't get observer service!");
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче