Bug 657297 part 2 - Add telemetry samples for initial I/O counters. r=tglek

This commit is contained in:
Mike Hommey 2011-05-22 08:24:32 +02:00
parent f17ef4149a
commit 969b71d749

View File

@ -38,9 +38,12 @@
#include "nsXPCOMGlue.h"
#include "nsXULAppAPI.h"
#ifdef XP_WIN
#if defined(XP_WIN)
#include <windows.h>
#include <stdlib.h>
#elif defined(XP_UNIX)
#include <sys/time.h>
#include <sys/resource.h>
#endif
#include <stdio.h>
@ -117,6 +120,7 @@ XRE_FreeAppDataType XRE_FreeAppData;
#ifdef XRE_HAS_DLL_BLOCKLIST
XRE_SetupDllBlocklistType XRE_SetupDllBlocklist;
#endif
XRE_TelemetryAddType XRE_TelemetryAdd;
XRE_mainType XRE_main;
static const nsDynamicFunctionLoad kXULFuncs[] = {
@ -126,6 +130,7 @@ static const nsDynamicFunctionLoad kXULFuncs[] = {
#ifdef XRE_HAS_DLL_BLOCKLIST
{ "XRE_SetupDllBlocklist", (NSFuncPtr*) &XRE_SetupDllBlocklist },
#endif
{ "XRE_TelemetryAdd", (NSFuncPtr*) &XRE_TelemetryAdd },
{ "XRE_main", (NSFuncPtr*) &XRE_main },
{ nsnull, nsnull }
};
@ -209,15 +214,19 @@ int main(int argc, char* argv[])
strcpy(++lastSlash, XPCOM_DLL);
#ifdef XP_WIN
int gotCounters;
#if defined(XP_UNIX)
struct rusage initialRUsage;
gotCounters = !getrusage(RUSAGE_SELF, &initialRUsage);
#elif defined(XP_WIN)
// GetProcessIoCounters().ReadOperationCount seems to have little to
// do with actual read operations. It reports 0 or 1 at this stage
// in the program. Luckily 1 coincides with when prefetch is
// enabled. If Windows prefetch didn't happen we can do our own
// faster dll preloading.
IO_COUNTERS ioCounters;
if (GetProcessIoCounters(GetCurrentProcess(), &ioCounters)
&& !ioCounters.ReadOperationCount)
gotCounters = GetProcessIoCounters(GetCurrentProcess(), &ioCounters);
if (gotCounters && !ioCounters.ReadOperationCount)
#endif
{
XPCOMGlueEnablePreload();
@ -240,6 +249,30 @@ int main(int argc, char* argv[])
XRE_SetupDllBlocklist();
#endif
if (gotCounters) {
#if defined(XP_WIN)
XRE_TelemetryAdd("Early.GlueStartup::ProcessIoCounters.ReadOperationCount",
int(ioCounters.ReadOperationCount), 1, 100, 12, HISTOGRAM_LINEAR);
XRE_TelemetryAdd("Early.GlueStartup::ProcessIoCounters.ReadTransferCount (KB)",
int(ioCounters.ReadTransferCount / 1024), 1, 50 * 1024, 12, HISTOGRAM_LINEAR);
IO_COUNTERS newIoCounters;
if (GetProcessIoCounters(GetCurrentProcess(), &newIoCounters)) {
XRE_TelemetryAdd("GlueStartup::ProcessIoCounters.ReadOperationCount",
int(newIoCounters.ReadOperationCount - ioCounters.ReadOperationCount), 1, 100, 12, HISTOGRAM_LINEAR);
XRE_TelemetryAdd("GlueStartup::ProcessIoCounters.ReadTransferCount (KB)",
int((newIoCounters.ReadTransferCount - ioCounters.ReadTransferCount) / 1024), 1, 50 * 1024, 12, HISTOGRAM_LINEAR);
}
#elif defined(XP_UNIX)
XRE_TelemetryAdd("Early.GlueStartup::HardFaults",
int(initialRUsage.ru_majflt), 1, 100, 12, HISTOGRAM_LINEAR);
struct rusage newRUsage;
if (!getrusage(RUSAGE_SELF, &newRUsage)) {
XRE_TelemetryAdd("GlueStartup::HardFaults",
int(newRUsage.ru_majflt - initialRUsage.ru_majflt), 1, 500, 12, HISTOGRAM_LINEAR);
}
#endif
}
int result;
{
ScopedLogging log;