[WIP] Set the MCJ in the candidate process
authorj-h.choi <j-h.choi@samsung.com>
Sun, 8 May 2022 23:41:35 +0000 (08:41 +0900)
committer조웅석/Common Platform Lab(SR)/삼성전자 <ws77.cho@samsung.com>
Mon, 11 Jul 2022 01:15:01 +0000 (10:15 +0900)
Change-Id: I95438e3a8ee4a4bbe5e538dc5add317d543a26f0

Managed/Tizen.Runtime/Preloader.cs
Managed/Tizen.Runtime/Profiler.cs

index 2cfc6f9..afb614d 100644 (file)
@@ -145,6 +145,8 @@ namespace Tizen.Runtime
 
             GC.Collect();
             GC.WaitForPendingFinalizers();
+
+            Profiler.SetCandidateProcessProfile();
         }
     }
 }
index 4c77fe1..9c40707 100644 (file)
@@ -1,37 +1,59 @@
-/*\r
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-using System;\r
-using System.Runtime;\r
-using System.Threading.Tasks;\r
-\r
-namespace Tizen.Runtime\r
-{\r
-    public class Profiler\r
-    {\r
-        private static void stop()\r
-        {\r
-            Console.WriteLine("Stop profile and write collected data");\r
-            ProfileOptimization.StartProfile(null);\r
-        }\r
-\r
-        public static void StopProfileAfterDelay(int sec)\r
-        {\r
-            Console.WriteLine($"Stop profile after {sec} sec");\r
-            Task.Delay(sec * 1000).ContinueWith(_ => stop());\r
-        }\r
-    }\r
-}\r
+/*
+ * 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());
+            }
+        }
+    }
+}