int main(int argc, char* argv[]) { char exePath[MAXPATHLEN]; #ifdef XP_MACOSX TriggerQuirks(); #endif nsresult rv = mozilla::BinaryPath::Get(argv[0], exePath); if (NS_FAILED(rv)) { Output("Couldn't calculate the application directory.\n"); return 255; } char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]); if (!lastSlash || (lastSlash - exePath > MAXPATHLEN - sizeof(XPCOM_DLL) - 1)) return 255; strcpy(++lastSlash, XPCOM_DLL); 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; gotCounters = GetProcessIoCounters(GetCurrentProcess(), &ioCounters); if (gotCounters && !ioCounters.ReadOperationCount) #endif { XPCOMGlueEnablePreload(); } rv = XPCOMGlueStartup(exePath); if (NS_FAILED(rv)) { Output("Couldn't load XPCOM.\n"); return 255; } // Reset exePath so that it is the directory name and not the xpcom dll name *lastSlash = 0; rv = XPCOMGlueLoadXULFunctions(kXULFuncs); if (NS_FAILED(rv)) { Output("Couldn't load XRE functions.\n"); return 255; } #ifdef XRE_HAS_DLL_BLOCKLIST XRE_SetupDllBlocklist(); #endif if (gotCounters) { #if defined(XP_WIN) XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_OPS, int(ioCounters.ReadOperationCount)); XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_TRANSFER, int(ioCounters.ReadTransferCount / 1024)); IO_COUNTERS newIoCounters; if (GetProcessIoCounters(GetCurrentProcess(), &newIoCounters)) { XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_OPS, int(newIoCounters.ReadOperationCount - ioCounters.ReadOperationCount)); XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_TRANSFER, int((newIoCounters.ReadTransferCount - ioCounters.ReadTransferCount) / 1024)); } #elif defined(XP_UNIX) XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_HARD_FAULTS, int(initialRUsage.ru_majflt)); struct rusage newRUsage; if (!getrusage(RUSAGE_SELF, &newRUsage)) { XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_HARD_FAULTS, int(newRUsage.ru_majflt - initialRUsage.ru_majflt)); } #endif } int result; { ScopedLogging log; result = do_main(exePath, argc, argv); } XPCOMGlueShutdown(); return result; }
int main(int argc, char* argv[]) { PRTime start = _PR_Now(); char exePath[MAXPATHLEN]; #ifdef XP_MACOSX TriggerQuirks(); #endif nsresult rv = mozilla::BinaryPath::Get(argv[0], exePath); if (NS_FAILED(rv)) { Output("Couldn't calculate the application directory.\n"); return 255; } char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]); if (!lastSlash || (size_t(lastSlash - exePath) > MAXPATHLEN - sizeof(XPCOM_DLL) - 1)) return 255; strcpy(++lastSlash, XPCOM_DLL); int gotCounters; #if defined(XP_UNIX) struct rusage initialRUsage; gotCounters = !getrusage(RUSAGE_SELF, &initialRUsage); #elif defined(XP_WIN) IO_COUNTERS ioCounters; gotCounters = GetProcessIoCounters(GetCurrentProcess(), &ioCounters); #endif // We do this because of data in bug 771745 XPCOMGlueEnablePreload(); rv = XPCOMGlueStartup(exePath); if (NS_FAILED(rv)) { Output("Couldn't load XPCOM.\n"); return 255; } // Reset exePath so that it is the directory name and not the xpcom dll name *lastSlash = 0; rv = XPCOMGlueLoadXULFunctions(kXULFuncs); if (NS_FAILED(rv)) { Output("Couldn't load XRE functions.\n"); return 255; } XRE_StartupTimelineRecord(mozilla::StartupTimeline::START, start); #ifdef XRE_HAS_DLL_BLOCKLIST XRE_SetupDllBlocklist(); #endif if (gotCounters) { #if defined(XP_WIN) XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_OPS, int(ioCounters.ReadOperationCount)); XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_TRANSFER, int(ioCounters.ReadTransferCount / 1024)); IO_COUNTERS newIoCounters; if (GetProcessIoCounters(GetCurrentProcess(), &newIoCounters)) { XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_OPS, int(newIoCounters.ReadOperationCount - ioCounters.ReadOperationCount)); XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_TRANSFER, int((newIoCounters.ReadTransferCount - ioCounters.ReadTransferCount) / 1024)); } #elif defined(XP_UNIX) XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_HARD_FAULTS, int(initialRUsage.ru_majflt)); struct rusage newRUsage; if (!getrusage(RUSAGE_SELF, &newRUsage)) { XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_HARD_FAULTS, int(newRUsage.ru_majflt - initialRUsage.ru_majflt)); } #endif } int result; { ScopedLogging log; result = do_main(argc, argv); } XPCOMGlueShutdown(); return result; }
int main(int argc, char* argv[]) { PRTime start = _PR_Now(); char exePath[MAXPATHLEN]; #ifdef XP_MACOSX TriggerQuirks(); #endif nsresult rv = mozilla::BinaryPath::Get(argv[0], exePath); if (NS_FAILED(rv)) { Output("Couldn't calculate the application directory.\n"); return 255; } char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]); if (!lastSlash || (size_t(lastSlash - exePath) > MAXPATHLEN - sizeof(XPCOM_DLL) - 1)) return 255; strcpy(++lastSlash, XPCOM_DLL); int gotCounters; #if defined(XP_UNIX) struct rusage initialRUsage; gotCounters = !getrusage(RUSAGE_SELF, &initialRUsage); #elif defined(XP_WIN) // Don't change the order of these enumeration constants, the order matters // for reporting telemetry data. If new values are added adjust the // STARTUP_USING_PRELOAD_TRIAL histogram. enum PreloadType{ PREFETCH_PRELOAD, PREFETCH_NO_PRELOAD, NO_PREFETCH_PRELOAD, NO_PREFETCH_NO_PRELOAD }; PreloadType preloadType; IO_COUNTERS ioCounters; gotCounters = GetProcessIoCounters(GetCurrentProcess(), &ioCounters); srand(time(NULL)); bool shouldUsePreload = rand() % 2 == 0; if (IsPrefetchDisabledViaService()) { if (shouldUsePreload) { preloadType = NO_PREFETCH_PRELOAD; } else { preloadType = NO_PREFETCH_NO_PRELOAD; } } else { if (shouldUsePreload) { preloadType = PREFETCH_PRELOAD; } else { preloadType = PREFETCH_NO_PRELOAD; } } if (shouldUsePreload) #endif { XPCOMGlueEnablePreload(); } rv = XPCOMGlueStartup(exePath); if (NS_FAILED(rv)) { Output("Couldn't load XPCOM.\n"); return 255; } // Reset exePath so that it is the directory name and not the xpcom dll name *lastSlash = 0; rv = XPCOMGlueLoadXULFunctions(kXULFuncs); if (NS_FAILED(rv)) { Output("Couldn't load XRE functions.\n"); return 255; } XRE_StartupTimelineRecord(mozilla::StartupTimeline::START, start); #ifdef XRE_HAS_DLL_BLOCKLIST XRE_SetupDllBlocklist(); #endif #if defined(XP_WIN) XRE_TelemetryAccumulate(mozilla::Telemetry::STARTUP_USING_PRELOAD_TRIAL, preloadType); #endif if (gotCounters) { #if defined(XP_WIN) XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_OPS, int(ioCounters.ReadOperationCount)); XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_TRANSFER, int(ioCounters.ReadTransferCount / 1024)); IO_COUNTERS newIoCounters; if (GetProcessIoCounters(GetCurrentProcess(), &newIoCounters)) { XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_OPS, int(newIoCounters.ReadOperationCount - ioCounters.ReadOperationCount)); XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_TRANSFER, int((newIoCounters.ReadTransferCount - ioCounters.ReadTransferCount) / 1024)); } #elif defined(XP_UNIX) XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_HARD_FAULTS, int(initialRUsage.ru_majflt)); struct rusage newRUsage; if (!getrusage(RUSAGE_SELF, &newRUsage)) { XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_HARD_FAULTS, int(newRUsage.ru_majflt - initialRUsage.ru_majflt)); } #endif } int result; { ScopedLogging log; result = do_main(argc, argv); } XPCOMGlueShutdown(); return result; }