Bug 1491478 - Properly attribute the memory report when using the GPU process. r=mstange

MozReview-Commit-ID: Db9mz5jQKwG
This commit is contained in:
Bobby Holley 2018-09-14 16:25:38 -07:00
Родитель 45da216271
Коммит 9942d41fd9
3 изменённых файлов: 35 добавлений и 2 удалений

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

@ -13,6 +13,7 @@
#include "gfxPrefs.h"
#include "GLContextProvider.h"
#include "GPUProcessHost.h"
#include "GPUProcessManager.h"
#include "mozilla/Assertions.h"
#include "mozilla/Telemetry.h"
#include "mozilla/TimeStamp.h"
@ -460,13 +461,30 @@ GPUParent::RecvNotifyGpuObservers(const nsCString& aTopic)
return IPC_OK();
}
/* static */ void
GPUParent::GetGPUProcessName(nsACString& aStr)
{
auto processType = XRE_GetProcessType();
unsigned pid = 0;
if (processType == GeckoProcessType_GPU) {
pid = getpid();
} else {
MOZ_DIAGNOSTIC_ASSERT(processType == GeckoProcessType_Default);
pid = GPUProcessManager::Get()->GPUProcessPid();
}
nsPrintfCString processName("GPU (pid %u)", pid);
aStr.Assign(processName);
}
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());
nsAutoCString processName;
GetGPUProcessName(processName);
mozilla::dom::MemoryReportRequestClient::Start(
aGeneration, aAnonymize, aMinimizeMemoryUsage, aDMDFile, processName);

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

@ -26,6 +26,11 @@ public:
static GPUParent* GetSingleton();
// Gets the name of the GPU process, in the format expected by about:memory.
// There must be a GPU process active, and the caller must be either in that
// process or the parent process.
static void GetGPUProcessName(nsACString& aStr);
bool Init(base::ProcessId aParentPid,
const char* aParentBuildID,
MessageLoop* aIOLoop,

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

@ -663,8 +663,18 @@ struct WebRenderMemoryReporterHelper {
void Report(size_t aBytes, const char* aName) const
{
// Generally, memory reporters pass the empty string as the process name to
// indicate "current process". However, if we're using a GPU process, the
// measurements will actually take place in that process, and it's easier to
// just note that here rather than trying to invoke the memory reporter in
// the GPU process.
nsAutoCString processName;
if (gfxConfig::IsEnabled(Feature::GPU_PROCESS)) {
GPUParent::GetGPUProcessName(processName);
}
nsPrintfCString path("explicit/gfx/webrender/%s", aName);
mCallback->Callback(EmptyCString(), path,
mCallback->Callback(processName, path,
nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES,
aBytes, EmptyCString(), mData);
}