Backout ac8d6c79a074 (bug 781133) and fccc68cc904f (bug 781124) for Windows bustage on a CLOSED TREE.

This commit is contained in:
Ryan VanderMeulen 2012-08-08 18:30:26 -04:00
Родитель e6e173db29
Коммит 33d9f3e2af
3 изменённых файлов: 33 добавлений и 65 удалений

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

@ -33,7 +33,6 @@
#include "nsPrintfCString.h" #include "nsPrintfCString.h"
#include "prsystem.h" #include "prsystem.h"
#include "prdtoa.h"
#ifdef XP_WIN #ifdef XP_WIN
#include "mozilla/widget/AudioSession.h" #include "mozilla/widget/AudioSession.h"
@ -111,7 +110,7 @@ PluginModuleParent::PluginModuleParent(const char* aFilePath)
, mPlugin(NULL) , mPlugin(NULL)
, mTaskFactory(this) , mTaskFactory(this)
#ifdef XP_WIN #ifdef XP_WIN
, mPluginCpuUsageOnHang() , mPluginCpuUsageOnHang(-1)
#endif #endif
#ifdef MOZ_CRASHREPORTER_INJECTOR #ifdef MOZ_CRASHREPORTER_INJECTOR
, mFlashProcess1(0) , mFlashProcess1(0)
@ -179,18 +178,11 @@ PluginModuleParent::WriteExtraDataForMinidump(AnnotationTable& notes)
if (!hangID.IsEmpty()) { if (!hangID.IsEmpty()) {
notes.Put(CS("HangID"), NS_ConvertUTF16toUTF8(hangID)); notes.Put(CS("HangID"), NS_ConvertUTF16toUTF8(hangID));
#ifdef XP_WIN #ifdef XP_WIN
if (mPluginCpuUsageOnHang.Length() > 0) { if (mPluginCpuUsageOnHang >= 0) {
notes.Put(CS("PluginCpuUsage"),
nsPrintfCString("%.2f", mPluginCpuUsageOnHang));
notes.Put(CS("NumberOfProcessors"), notes.Put(CS("NumberOfProcessors"),
nsPrintfCString("%d", PR_GetNumberOfProcessors())); nsPrintfCString("%d", PR_GetNumberOfProcessors()));
char buf[7];
PR_cnvtf(buf, NS_ARRAY_LENGTH(buf), 2, mPluginCpuUsageOnHang[0]);
notes.Put(CS("PluginCpuUsage"), CS(buf));
for (PRInt32 i=1; i<mPluginCpuUsageOnHang.Length(); ++i) {
PR_cnvtf(buf, NS_ARRAY_LENGTH(buf), 2, mPluginCpuUsageOnHang[i]);
notes.Put(nsPrintfCString("CpuUsageFlashProcess%d", i), CS(buf));
}
} }
#endif #endif
} }
@ -235,53 +227,42 @@ FileTimeToUTC(const FILETIME& ftime)
return li.QuadPart; return li.QuadPart;
} }
struct CpuUsageSamples
{
PRUint64 sampleTimes[2];
PRUint64 cpuTimes[2];
};
bool bool
GetProcessCpuUsage(const InfallibleTArray<base::ProcessHandle>& processHandles, InfallibleTArray<float>& cpuUsage) GetProcessCpuUsage(const base::ProcessHandle& processHandle, float& cpuUsage)
{ {
InfallibleTArray<CpuUsageSamples> samples(processHandles.Length());
FILETIME creationTime, exitTime, kernelTime, userTime, currentTime; FILETIME creationTime, exitTime, kernelTime, userTime, currentTime;
BOOL res; BOOL res;
for (PRUint32 i = 0; i < processHandles.Length(); ++i) { ::GetSystemTimeAsFileTime(&currentTime);
::GetSystemTimeAsFileTime(&currentTime); res = ::GetProcessTimes(processHandle, &creationTime, &exitTime, &kernelTime, &userTime);
res = ::GetProcessTimes(processHandles[i], &creationTime, &exitTime, &kernelTime, &userTime); if (!res) {
if (!res) { NS_WARNING("failed to get process times");
NS_WARNING("failed to get process times"); return false;
return false;
}
samples[i].sampleTimes[0] = FileTimeToUTC(currentTime);
samples[i].cpuTimes[0] = FileTimeToUTC(kernelTime) + FileTimeToUTC(userTime);
} }
PRUint64 sampleTimes[2];
PRUint64 cpuTimes[2];
sampleTimes[0] = FileTimeToUTC(currentTime);
cpuTimes[0] = FileTimeToUTC(kernelTime) + FileTimeToUTC(userTime);
// we already hung for a while, a little bit longer won't matter // we already hung for a while, a little bit longer won't matter
::Sleep(50); ::Sleep(50);
const PRInt32 numberOfProcessors = PR_GetNumberOfProcessors(); ::GetSystemTimeAsFileTime(&currentTime);
res = ::GetProcessTimes(processHandle, &creationTime, &exitTime, &kernelTime, &userTime);
for (PRUint32 i = 0; i < processHandles.Length(); ++i) { if (!res) {
::GetSystemTimeAsFileTime(&currentTime); NS_WARNING("failed to get process times");
res = ::GetProcessTimes(processHandles[i], &creationTime, &exitTime, &kernelTime, &userTime); return false;
if (!res) {
NS_WARNING("failed to get process times");
return false;
}
samples[i].sampleTimes[1] = FileTimeToUTC(currentTime);
samples[i].cpuTimes[1] = FileTimeToUTC(kernelTime) + FileTimeToUTC(userTime);
const PRUint64 deltaSampleTime = samples[i].sampleTimes[1] - samples[i].sampleTimes[0];
const PRUint64 deltaCpuTime = samples[i].cpuTimes[1] - samples[i].cpuTimes[0];
const float usage = 100.f * (float(deltaCpuTime) / deltaSampleTime) / numberOfProcessors;
cpuUsage.AppendElement(usage);
} }
sampleTimes[1] = FileTimeToUTC(currentTime);
cpuTimes[1] = FileTimeToUTC(kernelTime) + FileTimeToUTC(userTime);
const PRUint64 deltaSampleTime = sampleTimes[1] - sampleTimes[0];
const PRUint64 deltaCpuTime = cpuTimes[1] - cpuTimes[0];
cpuUsage = 100.f * (float(deltaCpuTime) / deltaSampleTime) / PR_GetNumberOfProcessors();
return true; return true;
} }
@ -307,22 +288,9 @@ PluginModuleParent::ShouldContinueFromReplyTimeout()
#endif #endif
#ifdef XP_WIN #ifdef XP_WIN
// collect cpu usage for plugin processes float cpuUsage;
if (GetProcessCpuUsage(OtherProcess(), cpuUsage)) {
InfallibleTArray<base::ProcessHandle> processHandles; mPluginCpuUsageOnHang = cpuUsage;
InfallibleTArray<float> cpuUsage;
base::ProcessHandle handle;
processHandles.AppendElement(OtherProcess());
if (mFlashProcess1 && base::OpenProcessHandle(mFlashProcess1, &handle)) {
processHandles.AppendElement(handle);
}
if (mFlashProcess2 && base::OpenProcessHandle(mFlashProcess2, &handle)) {
processHandles.AppendElement(handle);
}
if (!GetProcessCpuUsage(processHandles, cpuUsage)) {
mPluginCpuUsageOnHang.Clear();
} }
#endif #endif

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

@ -302,7 +302,7 @@ private:
nsString mBrowserDumpID; nsString mBrowserDumpID;
nsString mHangID; nsString mHangID;
#ifdef XP_WIN #ifdef XP_WIN
InfallibleTArray<float> mPluginCpuUsageOnHang; float mPluginCpuUsageOnHang;
#endif #endif
#ifdef MOZ_X11 #ifdef MOZ_X11

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

@ -79,7 +79,7 @@ var testObserver = {
// check cpu usage field // check cpu usage field
let extraData = parseKeyValuePairsFromFile(pluginExtraFile); let extraData = parseKeyValuePairsFromFile(pluginExtraFile);
ok("PluginCpuUsage" in extraData, "got extra field for plugin cpu usage"); ok("PluginCpuUsage" in extraData, "got extra field for plugin cpu usage");
let cpuUsage = parseFloat(extraData["PluginCpuUsage"]); let cpuUsage = parseFloat(extraData["PluginCpuUsage"].replace(',', '.'));
if (this.idleHang) { if (this.idleHang) {
ok(cpuUsage == 0, "plugin cpu usage is 0%"); ok(cpuUsage == 0, "plugin cpu usage is 0%");
} else { } else {