зеркало из https://github.com/mozilla/gecko-dev.git
Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
This commit is contained in:
Родитель
654acb89e0
Коммит
23572be8d6
|
@ -11,6 +11,7 @@
|
|||
#include "GPUProcessManager.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/dom/CheckerboardReportService.h"
|
||||
#include "mozilla/dom/MemoryReportRequest.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#if defined(XP_WIN)
|
||||
# include "mozilla/gfx/DeviceManagerDx.h"
|
||||
|
@ -174,6 +175,40 @@ GPUChild::RecvNotifyDeviceReset()
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
bool
|
||||
GPUChild::SendRequestMemoryReport(const uint32_t& aGeneration,
|
||||
const bool& aAnonymize,
|
||||
const bool& aMinimizeMemoryUsage,
|
||||
const MaybeFileDesc& aDMDFile)
|
||||
{
|
||||
mMemoryReportRequest = MakeUnique<MemoryReportRequestHost>(aGeneration);
|
||||
Unused << PGPUChild::SendRequestMemoryReport(
|
||||
aGeneration,
|
||||
aAnonymize,
|
||||
aMinimizeMemoryUsage,
|
||||
aDMDFile);
|
||||
return true;
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
GPUChild::RecvAddMemoryReport(const MemoryReport& aReport)
|
||||
{
|
||||
if (mMemoryReportRequest) {
|
||||
mMemoryReportRequest->RecvReport(aReport);
|
||||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
GPUChild::RecvFinishMemoryReport(const uint32_t& aGeneration)
|
||||
{
|
||||
if (mMemoryReportRequest) {
|
||||
mMemoryReportRequest->Finish(aGeneration);
|
||||
mMemoryReportRequest = nullptr;
|
||||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
void
|
||||
GPUChild::ActorDestroy(ActorDestroyReason aWhy)
|
||||
{
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
namespace mozilla {
|
||||
namespace ipc {
|
||||
class CrashReporterHost;
|
||||
} // namespace
|
||||
} // namespace ipc
|
||||
namespace dom {
|
||||
class MemoryReportRequestHost;
|
||||
} // namespace dom
|
||||
namespace gfx {
|
||||
|
||||
class GPUProcessHost;
|
||||
|
@ -23,6 +26,8 @@ class GPUChild final
|
|||
: public PGPUChild,
|
||||
public gfxVarReceiver
|
||||
{
|
||||
typedef mozilla::dom::MemoryReportRequestHost MemoryReportRequestHost;
|
||||
|
||||
public:
|
||||
explicit GPUChild(GPUProcessHost* aHost);
|
||||
~GPUChild();
|
||||
|
@ -46,12 +51,20 @@ public:
|
|||
mozilla::ipc::IPCResult RecvGraphicsError(const nsCString& aError) override;
|
||||
mozilla::ipc::IPCResult RecvNotifyUiObservers(const nsCString& aTopic) override;
|
||||
mozilla::ipc::IPCResult RecvNotifyDeviceReset() override;
|
||||
mozilla::ipc::IPCResult RecvAddMemoryReport(const MemoryReport& aReport) override;
|
||||
mozilla::ipc::IPCResult RecvFinishMemoryReport(const uint32_t& aGeneration) override;
|
||||
|
||||
bool SendRequestMemoryReport(const uint32_t& aGeneration,
|
||||
const bool& aAnonymize,
|
||||
const bool& aMinimizeMemoryUsage,
|
||||
const MaybeFileDesc& aDMDFile);
|
||||
|
||||
static void Destroy(UniquePtr<GPUChild>&& aChild);
|
||||
|
||||
private:
|
||||
GPUProcessHost* mHost;
|
||||
UniquePtr<ipc::CrashReporterHost> mCrashReporter;
|
||||
UniquePtr<MemoryReportRequestHost> mMemoryReportRequest;
|
||||
bool mGPUReady;
|
||||
};
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/dom/MemoryReportRequest.h"
|
||||
#include "mozilla/dom/VideoDecoderManagerChild.h"
|
||||
#include "mozilla/dom/VideoDecoderManagerParent.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/ipc/CrashReporterClient.h"
|
||||
|
@ -21,10 +24,8 @@
|
|||
#include "mozilla/layers/APZThreadUtils.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/dom/VideoDecoderManagerParent.h"
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
#include "mozilla/layers/ImageBridgeParent.h"
|
||||
#include "mozilla/dom/VideoDecoderManagerChild.h"
|
||||
#include "mozilla/layers/LayerTreeOwnerTracker.h"
|
||||
#include "mozilla/layers/UiCompositorControllerParent.h"
|
||||
#include "nsDebugImpl.h"
|
||||
|
@ -38,6 +39,7 @@
|
|||
#if defined(XP_WIN)
|
||||
# include "DeviceManagerD3D9.h"
|
||||
# include "mozilla/gfx/DeviceManagerDx.h"
|
||||
# include <process.h>
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
# include <gtk/gtk.h>
|
||||
|
@ -372,6 +374,19 @@ GPUParent::RecvNotifyGpuObservers(const nsCString& aTopic)
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
GPUParent::RecvRequestMemoryReport(const uint32_t& aGeneration,
|
||||
const bool& aAnonymize,
|
||||
const bool& aMinimizeMemoryUsage,
|
||||
const MaybeFileDesc& aDMDFile)
|
||||
{
|
||||
nsPrintfCString processName("GPU (pid %u)", (unsigned)getpid());
|
||||
|
||||
mozilla::dom::MemoryReportRequestClient::Start(
|
||||
aGeneration, aAnonymize, aMinimizeMemoryUsage, aDMDFile, processName);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
void
|
||||
GPUParent::ActorDestroy(ActorDestroyReason aWhy)
|
||||
{
|
||||
|
|
|
@ -54,6 +54,11 @@ public:
|
|||
mozilla::ipc::IPCResult RecvAddLayerTreeIdMapping(nsTArray<LayerTreeIdMapping>&& aMappings) override;
|
||||
mozilla::ipc::IPCResult RecvRemoveLayerTreeIdMapping(const LayerTreeIdMapping& aMapping) override;
|
||||
mozilla::ipc::IPCResult RecvNotifyGpuObservers(const nsCString& aTopic) override;
|
||||
mozilla::ipc::IPCResult RecvRequestMemoryReport(
|
||||
const uint32_t& generation,
|
||||
const bool& anonymize,
|
||||
const bool& minimizeMemoryUsage,
|
||||
const MaybeFileDesc& DMDFile) override;
|
||||
|
||||
void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "GPUProcessManager.h"
|
||||
#include "GPUProcessHost.h"
|
||||
#include "GPUProcessListener.h"
|
||||
#include "mozilla/MemoryReportingProcess.h"
|
||||
#include "mozilla/Sprintf.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
|
@ -906,5 +907,61 @@ GPUProcessManager::NotifyGpuObservers(const char* aTopic)
|
|||
return true;
|
||||
}
|
||||
|
||||
class GPUMemoryReporter : public MemoryReportingProcess
|
||||
{
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GPUMemoryReporter, override)
|
||||
|
||||
bool IsAlive() const override {
|
||||
if (GPUProcessManager* gpm = GPUProcessManager::Get()) {
|
||||
return !!gpm->GetGPUChild();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SendRequestMemoryReport(const uint32_t& aGeneration,
|
||||
const bool& aAnonymize,
|
||||
const bool& aMinimizeMemoryUsage,
|
||||
const dom::MaybeFileDesc& aDMDFile) override
|
||||
{
|
||||
GPUChild* child = GetChild();
|
||||
if (!child) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return child->SendRequestMemoryReport(
|
||||
aGeneration, aAnonymize, aMinimizeMemoryUsage, aDMDFile);
|
||||
}
|
||||
|
||||
int32_t Pid() const override {
|
||||
if (GPUChild* child = GetChild()) {
|
||||
return (int32_t)child->OtherPid();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
GPUChild* GetChild() const {
|
||||
if (GPUProcessManager* gpm = GPUProcessManager::Get()) {
|
||||
if (GPUChild* child = gpm->GetGPUChild()) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
~GPUMemoryReporter() = default;
|
||||
};
|
||||
|
||||
RefPtr<MemoryReportingProcess>
|
||||
GPUProcessManager::GetProcessMemoryReporter()
|
||||
{
|
||||
if (!mGPUChild) {
|
||||
return nullptr;
|
||||
}
|
||||
return new GPUMemoryReporter();
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -22,6 +22,7 @@ class nsBaseWidget;
|
|||
|
||||
|
||||
namespace mozilla {
|
||||
class MemoryReportingProcess;
|
||||
namespace layers {
|
||||
class IAPZCTreeManager;
|
||||
class CompositorOptions;
|
||||
|
@ -140,6 +141,10 @@ public:
|
|||
// Returns -1 if there is no GPU process, or the platform pid for it.
|
||||
base::ProcessId GPUProcessPid();
|
||||
|
||||
// If a GPU process is present, create a MemoryReportingProcess object.
|
||||
// Otherwise, return null.
|
||||
RefPtr<MemoryReportingProcess> GetProcessMemoryReporter();
|
||||
|
||||
// Returns access to the PGPU protocol if a GPU process is present.
|
||||
GPUChild* GetGPUChild() {
|
||||
return mGPUChild;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
include GraphicsMessages;
|
||||
include MemoryReportTypes;
|
||||
include protocol PCompositorBridge;
|
||||
include protocol PImageBridge;
|
||||
include protocol PVRManager;
|
||||
|
@ -85,6 +86,11 @@ parent:
|
|||
// observer service.
|
||||
async NotifyGpuObservers(nsCString aTopic);
|
||||
|
||||
async RequestMemoryReport(uint32_t generation,
|
||||
bool anonymize,
|
||||
bool minimizeMemoryUsage,
|
||||
MaybeFileDesc DMDFile);
|
||||
|
||||
child:
|
||||
// Sent when the GPU process has initialized devices. This occurs once, after
|
||||
// Init().
|
||||
|
@ -109,6 +115,9 @@ child:
|
|||
async UpdateChildKeyedScalars(KeyedScalarAction[] actions);
|
||||
|
||||
async NotifyDeviceReset();
|
||||
|
||||
async AddMemoryReport(MemoryReport aReport);
|
||||
async FinishMemoryReport(uint32_t aGeneration);
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
#endif
|
||||
|
||||
COMPONENT(SYSTEMINFO, nsSystemInfoConstructor)
|
||||
COMPONENT(MEMORY_REPORTER_MANAGER, nsMemoryReporterManagerConstructor)
|
||||
COMPONENT_M(MEMORY_REPORTER_MANAGER, nsMemoryReporterManagerConstructor, Module::ALLOW_IN_GPU_PROCESS)
|
||||
COMPONENT(MEMORY_INFO_DUMPER, nsMemoryInfoDumperConstructor)
|
||||
COMPONENT(IOUTIL, nsIOUtilConstructor)
|
||||
COMPONENT(CYCLE_COLLECTOR_LOGGER, nsCycleCollectorLoggerConstructor)
|
||||
|
|
|
@ -1766,7 +1766,9 @@ nsComponentManagerImpl::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
|
|||
}
|
||||
|
||||
n += sStaticModules->ShallowSizeOfIncludingThis(aMallocSizeOf);
|
||||
if (sModuleLocations) {
|
||||
n += sModuleLocations->ShallowSizeOfIncludingThis(aMallocSizeOf);
|
||||
}
|
||||
|
||||
n += mKnownStaticModules.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
||||
n += mKnownModules.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
||||
|
|
Загрузка…
Ссылка в новой задаче