зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1691128 - Propagate active browsing context ID to subprocesses via env vars so that early process startup samples aren't discarded when the real value is sent via ProfilerInitParams in the EnsureProfilerStarted IPC message. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D104297
This commit is contained in:
Родитель
48a87149cf
Коммит
5b4ef30e55
|
@ -3021,6 +3021,10 @@ static void PrintUsageThenExit(int aExitCode) {
|
|||
" Ignored if MOZ_PROFILER_STARTUP_FEATURES_BITFIELD is set.\n"
|
||||
" If unset, the platform default is used.\n"
|
||||
"\n"
|
||||
" MOZ_PROFILER_STARTUP_ACTIVE_BROWSING_CONTEXT_ID=<Number>\n"
|
||||
" This variable is used to propagate the activeBrowsingContextID of\n"
|
||||
" the profiler init params to subprocesses.\n"
|
||||
"\n"
|
||||
" Features: (x=unavailable, D/d=default/unavailable,\n"
|
||||
" S/s=MOZ_PROFILER_STARTUP extra default/unavailable)\n",
|
||||
unsigned(ActivePS::scMinimumBufferEntries),
|
||||
|
@ -4104,6 +4108,8 @@ void profiler_init(void* aStackTop) {
|
|||
PowerOfTwo32 capacity = PROFILER_DEFAULT_ENTRIES;
|
||||
Maybe<double> duration = Nothing();
|
||||
double interval = PROFILER_DEFAULT_INTERVAL;
|
||||
uint64_t activeBrowsingContextID =
|
||||
PROFILER_DEFAULT_ACTIVE_BROWSING_CONTEXT_ID;
|
||||
|
||||
{
|
||||
PSAutoLock lock(gPSMutex);
|
||||
|
@ -4231,8 +4237,25 @@ void profiler_init(void* aStackTop) {
|
|||
LOG("- MOZ_PROFILER_STARTUP_FILTERS = %s", startupFilters);
|
||||
}
|
||||
|
||||
const char* startupActiveBrowsingContextID =
|
||||
getenv("MOZ_PROFILER_STARTUP_ACTIVE_BROWSING_CONTEXT_ID");
|
||||
if (startupActiveBrowsingContextID &&
|
||||
startupActiveBrowsingContextID[0] != '\0') {
|
||||
std::istringstream iss(startupActiveBrowsingContextID);
|
||||
iss >> activeBrowsingContextID;
|
||||
if (!iss.fail()) {
|
||||
LOG("- MOZ_PROFILER_STARTUP_ACTIVE_BROWSING_CONTEXT_ID = %" PRIu64,
|
||||
activeBrowsingContextID);
|
||||
} else {
|
||||
LOG("- MOZ_PROFILER_STARTUP_ACTIVE_BROWSING_CONTEXT_ID not a valid "
|
||||
"uint64_t: %s",
|
||||
startupActiveBrowsingContextID);
|
||||
PrintUsageThenExit(1);
|
||||
}
|
||||
}
|
||||
|
||||
locked_profiler_start(lock, capacity, interval, features, filters.begin(),
|
||||
filters.length(), 0, duration);
|
||||
filters.length(), activeBrowsingContextID, duration);
|
||||
}
|
||||
|
||||
#if defined(MOZ_REPLACE_MALLOC) && defined(MOZ_PROFILER_MEMORY)
|
||||
|
@ -4470,6 +4493,11 @@ void GetProfilerEnvVarsForChildProcess(
|
|||
filtersString += filters[i];
|
||||
}
|
||||
aSetEnv("MOZ_PROFILER_STARTUP_FILTERS", filtersString.c_str());
|
||||
|
||||
auto activeBrowsingContextIDString =
|
||||
Smprintf("%" PRIu64, ActivePS::ActiveBrowsingContextID(lock));
|
||||
aSetEnv("MOZ_PROFILER_STARTUP_ACTIVE_BROWSING_CONTEXT_ID",
|
||||
activeBrowsingContextIDString.get());
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -350,6 +350,7 @@ static constexpr mozilla::PowerOfTwo32 PROFILER_DEFAULT_STARTUP_ENTRIES =
|
|||
// https://searchfox.org/mozilla-central/source/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoThread.java
|
||||
# define PROFILER_DEFAULT_INTERVAL 1 /* millisecond */
|
||||
# define PROFILER_MAX_INTERVAL 5000 /* milliseconds */
|
||||
# define PROFILER_DEFAULT_ACTIVE_BROWSING_CONTEXT_ID 0
|
||||
|
||||
// Initialize the profiler. If MOZ_PROFILER_STARTUP is set the profiler will
|
||||
// also be started. This call must happen before any other profiler calls
|
||||
|
|
Загрузка…
Ссылка в новой задаче