Bug 1661364 - Part 4: Disable process recycling when prealloc is disabled, r=kmag,jesup

Various tests disable process preallocation in order to get "stable" process
counts for testing purposes. In order to keep this behaviour, we need to disable
and shut down the recycled E10S process whenever the preallocator is disabled.

This is accomplished by having the preallocator expose its enabled status to
ContentParent, and by having the preallocator trigger ContentParent shutdown
when it is disabled.

This also has the benefit of hooking the recycler back into memory pressure
notifications, meaning it will be shut down if not in use when a memory pressure
event occurs.

Differential Revision: https://phabricator.services.mozilla.com/D88628
This commit is contained in:
Nika Layzell 2020-09-08 20:56:22 +00:00
Родитель 15199373b5
Коммит 5851505c99
3 изменённых файлов: 26 добавлений и 9 удалений

Просмотреть файл

@ -1998,15 +1998,14 @@ void ContentParent::ActorDestroy(ActorDestroyReason why) {
void ContentParent::ActorDealloc() { mSelfRef = nullptr; }
bool ContentParent::TryToRecycle() {
// We can only do this if we have a separate cache for recycled
// 'web' processes, and handle them differently than webIsolated ones
if (mRemoteType != DEFAULT_REMOTE_TYPE) {
return false;
}
// Don't bother recycling "web" processes if Fission is enabled, as they
// should be largely unused.
if (mozilla::FissionAutostart()) {
// Only try to recycle "web" content processes, as other remote types are
// generally more unique, and cannot be effectively re-used. This is disabled
// with Fission, as "web" content processes are no longer frequently used.
//
// Disabling the process pre-allocator will also disable process recycling,
// allowing for more consistent process counts under testing.
if (mRemoteType != DEFAULT_REMOTE_TYPE || mozilla::FissionAutostart() ||
!PreallocatedProcessManager::Enabled()) {
return false;
}

Просмотреть файл

@ -357,6 +357,14 @@ void PreallocatedProcessManagerImpl::CloseProcesses() {
process->ShutDownProcess(ContentParent::SEND_SHUTDOWN_MESSAGE);
// drop ref and let it free
}
// Make sure to also clear out the recycled E10S process cache, as it's also
// controlled by the same preference, and can be cleaned up due to memory
// pressure.
if (RefPtr<ContentParent> recycled =
ContentParent::sRecycledE10SProcess.forget()) {
recycled->MaybeBeginShutDown();
}
}
inline PreallocatedProcessManagerImpl*
@ -367,6 +375,14 @@ PreallocatedProcessManager::GetPPMImpl() {
return PreallocatedProcessManagerImpl::Singleton();
}
/* static */
bool PreallocatedProcessManager::Enabled() {
if (auto impl = GetPPMImpl()) {
return impl->mEnabled;
}
return false;
}
/* static */
void PreallocatedProcessManager::AddBlocker(const nsACString& aRemoteType,
ContentParent* aParent) {

Просмотреть файл

@ -37,6 +37,8 @@ class PreallocatedProcessManager final {
public:
static PreallocatedProcessManagerImpl* GetPPMImpl();
static bool Enabled();
/**
* Before first paint we don't want to allocate any processes in the
* background. To avoid that, the PreallocatedProcessManager won't start up