зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1492121 - Rename env-vars MOZ_PROFILER_* to MOZ_BASE_PROFILER_* - r=njn
Notice the extra 'BASE' in the env-var names. This is to control BaseProfiler separately from the Gecko Profiler. Differential Revision: https://phabricator.services.mozilla.com/D31928 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
061c135876
Коммит
11d60b8f63
|
@ -633,11 +633,11 @@ void ProfileBuffer::StreamSamplesToJSON(SpliceableJSONWriter& aWriter,
|
|||
unsigned long long pcULL = (unsigned long long)(uintptr_t)pc;
|
||||
SprintfLiteral(buf, "%#llx", pcULL);
|
||||
|
||||
// If the "MOZ_PROFILER_SYMBOLICATE" env-var is set, we add a local
|
||||
// If the "MOZ_BASE_PROFILER_SYMBOLICATE" env-var is set, we add a local
|
||||
// symbolication description to the PC address. This is off by default,
|
||||
// and mainly intended for local development.
|
||||
static const bool preSymbolicate = []() {
|
||||
const char* symbolicate = getenv("MOZ_PROFILER_SYMBOLICATE");
|
||||
const char* symbolicate = getenv("MOZ_BASE_PROFILER_SYMBOLICATE");
|
||||
return symbolicate && symbolicate[0] != '\0';
|
||||
}();
|
||||
if (preSymbolicate) {
|
||||
|
|
|
@ -189,7 +189,7 @@ static uint32_t DefaultFeatures() {
|
|||
ProfilerFeature::Responsiveness;
|
||||
}
|
||||
|
||||
// Extra default features when MOZ_PROFILER_STARTUP is set (even if not
|
||||
// Extra default features when MOZ_BASE_PROFILER_STARTUP is set (even if not
|
||||
// available).
|
||||
static uint32_t StartupExtraDefaultFeatures() {
|
||||
// Enable mainthreadio by default for startup profiles as startup is heavy on
|
||||
|
@ -1683,52 +1683,54 @@ static void PrintUsageThenExit(int aExitCode) {
|
|||
"\n"
|
||||
"Profiler environment variable usage:\n"
|
||||
"\n"
|
||||
" MOZ_PROFILER_HELP\n"
|
||||
" MOZ_BASE_PROFILER_HELP\n"
|
||||
" If set to any value, prints this message.\n"
|
||||
" Use MOZ_PROFILER_HELP for Gecko Profiler help.\n"
|
||||
"\n"
|
||||
" MOZ_BASE_PROFILER_{,DEBUG_,VERBOSE}LOGGING\n"
|
||||
" Enables logging to stdout. The levels of logging available are\n"
|
||||
" 'MOZ_BASE_PROFILER_LOGGING' (least verbose), '..._DEBUG_LOGGING',\n"
|
||||
" '..._VERBOSE_LOGGING' (most verbose)\n"
|
||||
"\n"
|
||||
" MOZ_PROFILER_STARTUP\n"
|
||||
" MOZ_BASE_PROFILER_STARTUP\n"
|
||||
" If set to any value, starts the profiler immediately on start-up.\n"
|
||||
" Useful if you want profile code that runs very early.\n"
|
||||
"\n"
|
||||
" MOZ_PROFILER_STARTUP_ENTRIES=<1..>\n"
|
||||
" If MOZ_PROFILER_STARTUP is set, specifies the number of entries per\n"
|
||||
" process in the profiler's circular buffer when the profiler is first\n"
|
||||
" started.\n"
|
||||
" MOZ_BASE_PROFILER_STARTUP_ENTRIES=<1..>\n"
|
||||
" If MOZ_BASE_PROFILER_STARTUP is set, specifies the number of entries\n"
|
||||
" per process in the profiler's circular buffer when the profiler is\n"
|
||||
" first started.\n"
|
||||
" If unset, the platform default is used:\n"
|
||||
" %u entries per process, or %u when MOZ_PROFILER_STARTUP is set.\n"
|
||||
" %u entries per process, or %u when MOZ_BASE_PROFILER_STARTUP is set.\n"
|
||||
" (%zu bytes per entry -> %zu or %zu total bytes per process)\n"
|
||||
"\n"
|
||||
" MOZ_PROFILER_STARTUP_DURATION=<1..>\n"
|
||||
" If MOZ_PROFILER_STARTUP is set, specifies the maximum life time of\n"
|
||||
" entries in the the profiler's circular buffer when the profiler is\n"
|
||||
" first started, in seconds.\n"
|
||||
" MOZ_BASE_PROFILER_STARTUP_DURATION=<1..>\n"
|
||||
" If MOZ_BASE_PROFILER_STARTUP is set, specifies the maximum life time\n"
|
||||
" of entries in the the profiler's circular buffer when the profiler\n"
|
||||
" is first started, in seconds.\n"
|
||||
" If unset, the life time of the entries will only be restricted by\n"
|
||||
" MOZ_PROFILER_STARTUP_ENTRIES (or its default value), and no\n"
|
||||
" MOZ_BASE_PROFILER_STARTUP_ENTRIES (or its default value), and no\n"
|
||||
" additional time duration restriction will be applied.\n"
|
||||
"\n"
|
||||
" MOZ_PROFILER_STARTUP_INTERVAL=<1..1000>\n"
|
||||
" If MOZ_PROFILER_STARTUP is set, specifies the sample interval,\n"
|
||||
" MOZ_BASE_PROFILER_STARTUP_INTERVAL=<1..1000>\n"
|
||||
" If MOZ_BASE_PROFILER_STARTUP is set, specifies the sample interval,\n"
|
||||
" measured in milliseconds, when the profiler is first started.\n"
|
||||
" If unset, the platform default is used.\n"
|
||||
"\n"
|
||||
" MOZ_PROFILER_STARTUP_FEATURES_BITFIELD=<Number>\n"
|
||||
" If MOZ_PROFILER_STARTUP is set, specifies the profiling features, as\n"
|
||||
" the integer value of the features bitfield.\n"
|
||||
" If unset, the value from MOZ_PROFILER_STARTUP_FEATURES is used.\n"
|
||||
" MOZ_BASE_PROFILER_STARTUP_FEATURES_BITFIELD=<Number>\n"
|
||||
" If MOZ_BASE_PROFILER_STARTUP is set, specifies the profiling\n"
|
||||
" features, as the integer value of the features bitfield.\n"
|
||||
" If unset, the value from MOZ_BASE_PROFILER_STARTUP_FEATURES is used.\n"
|
||||
"\n"
|
||||
" MOZ_PROFILER_STARTUP_FEATURES=<Features>\n"
|
||||
" If MOZ_PROFILER_STARTUP is set, specifies the profiling features, as\n"
|
||||
" a comma-separated list of strings.\n"
|
||||
" Ignored if MOZ_PROFILER_STARTUP_FEATURES_BITFIELD is set.\n"
|
||||
" MOZ_BASE_PROFILER_STARTUP_FEATURES=<Features>\n"
|
||||
" If MOZ_BASE_PROFILER_STARTUP is set, specifies the profiling\n"
|
||||
" features, as a comma-separated list of strings.\n"
|
||||
" Ignored if MOZ_BASE_PROFILER_STARTUP_FEATURES_BITFIELD is set.\n"
|
||||
" If unset, the platform default is used.\n"
|
||||
"\n"
|
||||
" Features: (x=unavailable, D/d=default/unavailable,\n"
|
||||
" S/s=MOZ_PROFILER_STARTUP extra default/unavailable)\n",
|
||||
" S/s=MOZ_BASE_PROFILER_STARTUP extra "
|
||||
"default/unavailable)\n",
|
||||
unsigned(PROFILER_DEFAULT_ENTRIES),
|
||||
unsigned(PROFILER_DEFAULT_STARTUP_ENTRIES), sizeof(ProfileBufferEntry),
|
||||
sizeof(ProfileBufferEntry) * PROFILER_DEFAULT_ENTRIES,
|
||||
|
@ -1746,21 +1748,22 @@ static void PrintUsageThenExit(int aExitCode) {
|
|||
printf(
|
||||
" - \"default\" (All above D+S defaults)\n"
|
||||
"\n"
|
||||
" MOZ_PROFILER_STARTUP_FILTERS=<Filters>\n"
|
||||
" If MOZ_PROFILER_STARTUP is set, specifies the thread filters, as a\n"
|
||||
" MOZ_BASE_PROFILER_STARTUP_FILTERS=<Filters>\n"
|
||||
" If MOZ_BASE_PROFILER_STARTUP is set, specifies the thread filters, as "
|
||||
"a\n"
|
||||
" comma-separated list of strings. A given thread will be sampled if\n"
|
||||
" any of the filters is a case-insensitive substring of the thread\n"
|
||||
" name. If unset, a default is used.\n"
|
||||
"\n"
|
||||
" MOZ_PROFILER_SHUTDOWN\n"
|
||||
" MOZ_BASE_PROFILER_SHUTDOWN\n"
|
||||
" If set, the profiler saves a profile to the named file on shutdown.\n"
|
||||
"\n"
|
||||
" MOZ_PROFILER_SYMBOLICATE\n"
|
||||
" MOZ_BASE_PROFILER_SYMBOLICATE\n"
|
||||
" If set, the profiler will pre-symbolicate profiles.\n"
|
||||
" *Note* This will add a significant pause when gathering data, and\n"
|
||||
" is intended mainly for local development.\n"
|
||||
"\n"
|
||||
" MOZ_PROFILER_LUL_TEST\n"
|
||||
" MOZ_BASE_PROFILER_LUL_TEST\n"
|
||||
" If set to any value, runs LUL unit tests at startup.\n"
|
||||
"\n"
|
||||
" This platform %s native unwinding.\n"
|
||||
|
@ -2166,7 +2169,7 @@ void profiler_init(void* aStackTop) {
|
|||
|
||||
MOZ_RELEASE_ASSERT(!CorePS::Exists());
|
||||
|
||||
if (getenv("MOZ_PROFILER_HELP")) {
|
||||
if (getenv("MOZ_BASE_PROFILER_HELP")) {
|
||||
PrintUsageThenExit(0); // terminates execution
|
||||
}
|
||||
|
||||
|
@ -2201,17 +2204,17 @@ void profiler_init(void* aStackTop) {
|
|||
// startup, even if no profiling is actually to be done. So, instead, it is
|
||||
// created on demand at the first call to PlatformStart().
|
||||
|
||||
const char* startupEnv = getenv("MOZ_PROFILER_STARTUP");
|
||||
const char* startupEnv = getenv("MOZ_BASE_PROFILER_STARTUP");
|
||||
if (!startupEnv || startupEnv[0] == '\0') {
|
||||
return;
|
||||
}
|
||||
|
||||
LOG("- MOZ_PROFILER_STARTUP is set");
|
||||
LOG("- MOZ_BASE_PROFILER_STARTUP is set");
|
||||
|
||||
// Startup default capacity may be different.
|
||||
capacity = PROFILER_DEFAULT_STARTUP_ENTRIES;
|
||||
|
||||
const char* startupCapacity = getenv("MOZ_PROFILER_STARTUP_ENTRIES");
|
||||
const char* startupCapacity = getenv("MOZ_BASE_PROFILER_STARTUP_ENTRIES");
|
||||
if (startupCapacity && startupCapacity[0] != '\0') {
|
||||
errno = 0;
|
||||
long capacityLong = strtol(startupCapacity, nullptr, 10);
|
||||
|
@ -2221,42 +2224,42 @@ void profiler_init(void* aStackTop) {
|
|||
static_cast<uint64_t>(capacityLong) <=
|
||||
static_cast<uint64_t>(UINT32_MAX)) {
|
||||
capacity = static_cast<uint32_t>(capacityLong);
|
||||
LOG("- MOZ_PROFILER_STARTUP_ENTRIES = %u", unsigned(capacity));
|
||||
LOG("- MOZ_BASE_PROFILER_STARTUP_ENTRIES = %u", unsigned(capacity));
|
||||
} else {
|
||||
LOG("- MOZ_PROFILER_STARTUP_ENTRIES not a valid integer: %s",
|
||||
LOG("- MOZ_BASE_PROFILER_STARTUP_ENTRIES not a valid integer: %s",
|
||||
startupCapacity);
|
||||
PrintUsageThenExit(1);
|
||||
}
|
||||
}
|
||||
|
||||
const char* startupDuration = getenv("MOZ_PROFILER_STARTUP_DURATION");
|
||||
const char* startupDuration = getenv("MOZ_BASE_PROFILER_STARTUP_DURATION");
|
||||
if (startupDuration && startupDuration[0] != '\0') {
|
||||
// TODO implement if needed
|
||||
MOZ_CRASH("MOZ_PROFILER_STARTUP_DURATION unsupported");
|
||||
MOZ_CRASH("MOZ_BASE_PROFILER_STARTUP_DURATION unsupported");
|
||||
// errno = 0;
|
||||
// double durationVal = PR_strtod(startupDuration, nullptr);
|
||||
// if (errno == 0 && durationVal >= 0.0) {
|
||||
// if (durationVal > 0.0) {
|
||||
// duration = Some(durationVal);
|
||||
// }
|
||||
// LOG("- MOZ_PROFILER_STARTUP_DURATION = %f", durationVal);
|
||||
// LOG("- MOZ_BASE_PROFILER_STARTUP_DURATION = %f", durationVal);
|
||||
// } else {
|
||||
// LOG("- MOZ_PROFILER_STARTUP_DURATION not a valid float: %s",
|
||||
// LOG("- MOZ_BASE_PROFILER_STARTUP_DURATION not a valid float: %s",
|
||||
// startupDuration);
|
||||
// PrintUsageThenExit(1);
|
||||
// }
|
||||
}
|
||||
|
||||
const char* startupInterval = getenv("MOZ_PROFILER_STARTUP_INTERVAL");
|
||||
const char* startupInterval = getenv("MOZ_BASE_PROFILER_STARTUP_INTERVAL");
|
||||
if (startupInterval && startupInterval[0] != '\0') {
|
||||
// TODO implement if needed
|
||||
MOZ_CRASH("MOZ_PROFILER_STARTUP_INTERVAL unsupported");
|
||||
MOZ_CRASH("MOZ_BASE_PROFILER_STARTUP_INTERVAL unsupported");
|
||||
// errno = 0;
|
||||
// interval = PR_strtod(startupInterval, nullptr);
|
||||
// if (errno == 0 && interval > 0.0 && interval <= 1000.0) {
|
||||
// LOG("- MOZ_PROFILER_STARTUP_INTERVAL = %f", interval);
|
||||
// LOG("- MOZ_BASE_PROFILER_STARTUP_INTERVAL = %f", interval);
|
||||
// } else {
|
||||
// LOG("- MOZ_PROFILER_STARTUP_INTERVAL not a valid float: %s",
|
||||
// LOG("- MOZ_BASE_PROFILER_STARTUP_INTERVAL not a valid float: %s",
|
||||
// startupInterval);
|
||||
// PrintUsageThenExit(1);
|
||||
// }
|
||||
|
@ -2265,19 +2268,22 @@ void profiler_init(void* aStackTop) {
|
|||
features |= StartupExtraDefaultFeatures() & AvailableFeatures();
|
||||
|
||||
const char* startupFeaturesBitfield =
|
||||
getenv("MOZ_PROFILER_STARTUP_FEATURES_BITFIELD");
|
||||
getenv("MOZ_BASE_PROFILER_STARTUP_FEATURES_BITFIELD");
|
||||
if (startupFeaturesBitfield && startupFeaturesBitfield[0] != '\0') {
|
||||
errno = 0;
|
||||
features = strtol(startupFeaturesBitfield, nullptr, 10);
|
||||
if (errno == 0 && features != 0) {
|
||||
LOG("- MOZ_PROFILER_STARTUP_FEATURES_BITFIELD = %d", features);
|
||||
LOG("- MOZ_BASE_PROFILER_STARTUP_FEATURES_BITFIELD = %d", features);
|
||||
} else {
|
||||
LOG("- MOZ_PROFILER_STARTUP_FEATURES_BITFIELD not a valid integer: %s",
|
||||
LOG("- MOZ_BASE_PROFILER_STARTUP_FEATURES_BITFIELD not a valid "
|
||||
"integer: "
|
||||
"%s",
|
||||
startupFeaturesBitfield);
|
||||
PrintUsageThenExit(1);
|
||||
}
|
||||
} else {
|
||||
const char* startupFeatures = getenv("MOZ_PROFILER_STARTUP_FEATURES");
|
||||
const char* startupFeatures =
|
||||
getenv("MOZ_BASE_PROFILER_STARTUP_FEATURES");
|
||||
if (startupFeatures && startupFeatures[0] != '\0') {
|
||||
// Interpret startupFeatures as a list of feature strings, separated by
|
||||
// commas.
|
||||
|
@ -2287,14 +2293,14 @@ void profiler_init(void* aStackTop) {
|
|||
features = ParseFeaturesFromStringArray(featureStringArray.begin(),
|
||||
featureStringArray.length(),
|
||||
/* aIsStartup */ true);
|
||||
LOG("- MOZ_PROFILER_STARTUP_FEATURES = %d", features);
|
||||
LOG("- MOZ_BASE_PROFILER_STARTUP_FEATURES = %d", features);
|
||||
}
|
||||
}
|
||||
|
||||
const char* startupFilters = getenv("MOZ_PROFILER_STARTUP_FILTERS");
|
||||
const char* startupFilters = getenv("MOZ_BASE_PROFILER_STARTUP_FILTERS");
|
||||
if (startupFilters && startupFilters[0] != '\0') {
|
||||
filters = SplitAtCommas(startupFilters, filterStorage);
|
||||
LOG("- MOZ_PROFILER_STARTUP_FILTERS = %s", startupFilters);
|
||||
LOG("- MOZ_BASE_PROFILER_STARTUP_FILTERS = %s", startupFilters);
|
||||
}
|
||||
|
||||
locked_profiler_start(lock, capacity, interval, features, filters.begin(),
|
||||
|
@ -2334,7 +2340,7 @@ void profiler_shutdown() {
|
|||
|
||||
// Save the profile on shutdown if requested.
|
||||
if (ActivePS::Exists(lock)) {
|
||||
const char* filename = getenv("MOZ_PROFILER_SHUTDOWN");
|
||||
const char* filename = getenv("MOZ_BASE_PROFILER_SHUTDOWN");
|
||||
if (filename) {
|
||||
locked_profiler_save_profile_to_file(lock, filename,
|
||||
/* aIsShuttingDown */ true);
|
||||
|
@ -2450,23 +2456,23 @@ void GetProfilerEnvVarsForChildProcess(
|
|||
PSAutoLock lock;
|
||||
|
||||
if (!ActivePS::Exists(lock)) {
|
||||
aSetEnv("MOZ_PROFILER_STARTUP", "");
|
||||
aSetEnv("MOZ_BASE_PROFILER_STARTUP", "");
|
||||
return;
|
||||
}
|
||||
|
||||
aSetEnv("MOZ_PROFILER_STARTUP", "1");
|
||||
aSetEnv("MOZ_BASE_PROFILER_STARTUP", "1");
|
||||
auto capacityString = Smprintf("%d", ActivePS::Capacity(lock));
|
||||
aSetEnv("MOZ_PROFILER_STARTUP_ENTRIES", capacityString.get());
|
||||
aSetEnv("MOZ_BASE_PROFILER_STARTUP_ENTRIES", capacityString.get());
|
||||
|
||||
// Use AppendFloat instead of Smprintf with %f because the decimal
|
||||
// separator used by %f is locale-dependent. But the string we produce needs
|
||||
// to be parseable by strtod, which only accepts the period character as a
|
||||
// decimal separator. AppendFloat always uses the period character.
|
||||
std::string intervalString = std::to_string(ActivePS::Interval(lock));
|
||||
aSetEnv("MOZ_PROFILER_STARTUP_INTERVAL", intervalString.c_str());
|
||||
aSetEnv("MOZ_BASE_PROFILER_STARTUP_INTERVAL", intervalString.c_str());
|
||||
|
||||
auto featuresString = Smprintf("%d", ActivePS::Features(lock));
|
||||
aSetEnv("MOZ_PROFILER_STARTUP_FEATURES_BITFIELD", featuresString.get());
|
||||
aSetEnv("MOZ_BASE_PROFILER_STARTUP_FEATURES_BITFIELD", featuresString.get());
|
||||
|
||||
std::string filtersString;
|
||||
const Vector<std::string>& filters = ActivePS::Filters(lock);
|
||||
|
@ -2476,7 +2482,7 @@ void GetProfilerEnvVarsForChildProcess(
|
|||
filtersString += ",";
|
||||
}
|
||||
}
|
||||
aSetEnv("MOZ_PROFILER_STARTUP_FILTERS", filtersString.c_str());
|
||||
aSetEnv("MOZ_BASE_PROFILER_STARTUP_FILTERS", filtersString.c_str());
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -249,8 +249,8 @@ static constexpr uint32_t PROFILER_DEFAULT_STARTUP_ENTRIES =
|
|||
# define PROFILER_DEFAULT_DURATION 20
|
||||
# define PROFILER_DEFAULT_INTERVAL 1
|
||||
|
||||
// Initialize the profiler. If MOZ_PROFILER_STARTUP is set the profiler will
|
||||
// also be started. This call must happen before any other profiler calls
|
||||
// Initialize the profiler. If MOZ_BASE_PROFILER_STARTUP is set the profiler
|
||||
// will also be started. This call must happen before any other profiler calls
|
||||
// (except profiler_start(), which will call profiler_init() if it hasn't
|
||||
// already run).
|
||||
MFBT_API void profiler_init(void* stackTop);
|
||||
|
@ -939,7 +939,7 @@ class MOZ_RAII AutoProfilerTracing {
|
|||
const mozilla::Maybe<uint32_t> mDocShellHistoryId;
|
||||
};
|
||||
|
||||
// Get the MOZ_PROFILER_STARTUP* environment variables that should be
|
||||
// Get the MOZ_BASE_PROFILER_STARTUP* environment variables that should be
|
||||
// supplied to a child process that is about to be launched, in order
|
||||
// to make that child process start with the same profiler settings as
|
||||
// in the current process. The given function is invoked once for
|
||||
|
|
|
@ -2207,6 +2207,9 @@ static void PrintUsageThenExit(int aExitCode) {
|
|||
"\n"
|
||||
" MOZ_PROFILER_HELP\n"
|
||||
" If set to any value, prints this message.\n"
|
||||
#ifdef MOZ_BASE_PROFILER
|
||||
" Use MOZ_BASE_PROFILER_HELP for BaseProfiler help.\n"
|
||||
#endif
|
||||
"\n"
|
||||
" MOZ_LOG\n"
|
||||
" Enables logging. The levels of logging available are\n"
|
||||
|
|
Загрузка…
Ссылка в новой задаче