+
+ // set profile.data path and collect/use it if it non-exists/exists.
+ if (profile) {
+ char multiCoreJitProfile[strlen(localDataPath) + strlen(PROFILE_BASENAME) + 1];
+ memcpy(multiCoreJitProfile, localDataPath, strlen(localDataPath) + 1);
+ strncat(multiCoreJitProfile, PROFILE_BASENAME, strlen(PROFILE_BASENAME));
+
+ setEnvironmentVariable("COMPlus_MultiCoreJitProfile", multiCoreJitProfile);
+ setEnvironmentVariable("COMPlus_MultiCoreJitMinNumCpus", "1");
+
+ if (exist(multiCoreJitProfile)) {
+ setEnvironmentVariable("COMPlus_MultiCoreJitNoProfileGather", "1");
+ _INFO("MCJ playing start for %s", appId);
+ } else {
+ setEnvironmentVariable("COMPlus_MultiCoreJitNoProfileGather", "0");
+ // stop profiling and write collected data after delay if env value is set.
+ char *env = getenv("CLR_MCJ_PROFILE_WRITE_DELAY");
+ if (env != nullptr) {
+ int delay = std::atoi(env);
+ // To avoid undefined behavior by out-of-range input(atoi), set max delay value to 100.
+ if (delay > 0) {
+ if (delay > MAX_DELAY_SEC) delay = MAX_DELAY_SEC;
+ stopProfileAfterDelay(delay);
+ }
+ }
+ _INFO("MCJ recording start for %s", appId);
+ }
+ }