From c9bde4b5405055b8bd05e1ba0a01b6381dcd736e Mon Sep 17 00:00:00 2001 From: "j-h.choi" Date: Mon, 9 May 2022 08:41:35 +0900 Subject: [PATCH] [WIP] Set the MCJ in the candidate process Change-Id: I95438e3a8ee4a4bbe5e538dc5add317d543a26f0 --- Managed/Tizen.Runtime/Preloader.cs | 2 + Managed/Tizen.Runtime/Profiler.cs | 96 +++++++++++++++++++++++--------------- 2 files changed, 61 insertions(+), 37 deletions(-) diff --git a/Managed/Tizen.Runtime/Preloader.cs b/Managed/Tizen.Runtime/Preloader.cs index 2cfc6f9..afb614d 100644 --- a/Managed/Tizen.Runtime/Preloader.cs +++ b/Managed/Tizen.Runtime/Preloader.cs @@ -145,6 +145,8 @@ namespace Tizen.Runtime GC.Collect(); GC.WaitForPendingFinalizers(); + + Profiler.SetCandidateProcessProfile(); } } } diff --git a/Managed/Tizen.Runtime/Profiler.cs b/Managed/Tizen.Runtime/Profiler.cs index 4c77fe1..9c40707 100644 --- a/Managed/Tizen.Runtime/Profiler.cs +++ b/Managed/Tizen.Runtime/Profiler.cs @@ -1,37 +1,59 @@ -/* - * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Runtime; -using System.Threading.Tasks; - -namespace Tizen.Runtime -{ - public class Profiler - { - private static void stop() - { - Console.WriteLine("Stop profile and write collected data"); - ProfileOptimization.StartProfile(null); - } - - public static void StopProfileAfterDelay(int sec) - { - Console.WriteLine($"Stop profile after {sec} sec"); - Task.Delay(sec * 1000).ContinueWith(_ => stop()); - } - } -} +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.IO; +using System.Runtime; +using System.Threading.Tasks; + +namespace Tizen.Runtime +{ + public class Profiler + { + + const string profilePath = "/home/owner/data/.__tizen_candidate_profile_data"; + + private static void stop() + { + Console.WriteLine("Stop profile and write collected data"); + ProfileOptimization.StartProfile(null); + } + + public static void StopProfileAfterDelay(int sec) + { + Console.WriteLine($"Stop profile after {sec} sec"); + Task.Delay(sec * 1000).ContinueWith(_ => stop()); + } + + public static void SetCandidateProcessProfile() + { + try + { + if (File.Exists(profilePath)) + { + Environment.SetEnvironmentVariable("COMPlus_MultiCoreJitNoProfileGather", "1"); + Environment.SetEnvironmentVariable("COMPlus_MultiCoreJitMinNumCpus", "1"); + ProfileOptimization.SetProfileRoot(""); + ProfileOptimization.StartProfile(profilePath); + } + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + } + } + } +} -- 2.7.4