From 969b71d74930bd321be3f750a846ad7fe2411a15 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Sun, 22 May 2011 08:24:32 +0200 Subject: [PATCH] Bug 657297 part 2 - Add telemetry samples for initial I/O counters. r=tglek --- browser/app/nsBrowserApp.cpp | 41 ++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/browser/app/nsBrowserApp.cpp b/browser/app/nsBrowserApp.cpp index 78cca4760eb..fd95e9f9e96 100644 --- a/browser/app/nsBrowserApp.cpp +++ b/browser/app/nsBrowserApp.cpp @@ -38,9 +38,12 @@ #include "nsXPCOMGlue.h" #include "nsXULAppAPI.h" -#ifdef XP_WIN +#if defined(XP_WIN) #include #include +#elif defined(XP_UNIX) +#include +#include #endif #include @@ -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;