[WRTjs][VD] Add Thread boost API 96/320296/3
authorYoungman Son <yman.son@samsung.com>
Tue, 12 Nov 2024 11:01:05 +0000 (20:01 +0900)
committerBot Blink <blinkbot@samsung.com>
Wed, 13 Nov 2024 03:27:16 +0000 (03:27 +0000)
Before : Use WebEngine's MM Type Boosting
After: Apply RR Boosting according to the performance team guide.

For MM Type, the priority is very high
And boosting is affected by video playback/stop
So the WRT directly controls the boosting of needed threads

Change-Id: I818a35dcf8d78045ac6a69f669f9c0e977c671c3
Signed-off-by: Youngman Son <yman.son@samsung.com>
wrt/filenames.gni
wrt/src/base/platform_info.cc
wrt/src/base/platform_info.h
wrt/src/browser/tv/native_web_runtime_delegate_tv.cc
wrt/src/browser/tv/wrt_native_window_tv.cc
wrt/src/common/tv/wrt_thread_booster.cc [new file with mode: 0755]
wrt/src/common/tv/wrt_thread_booster.h [new file with mode: 0755]
wrt/src/renderer/tv/wrt_renderer_client_tv.cc

index f361bc995333e9291e2a678993bfea67c2158a44..4650ae431d72596f8a999e0cafc92a592da07982 100644 (file)
@@ -229,6 +229,8 @@ wrt_lib_sources_tv = [
   "src/common/tv/wrt_profiler.h",
   "src/common/tv/wrt_lib_wrapper.cc",
   "src/common/tv/wrt_lib_wrapper.h",
+  "src/common/tv/wrt_thread_booster.cc",
+  "src/common/tv/wrt_thread_booster.h",
   "src/renderer/tv/wrt_renderer_client_tv.cc",
   "src/renderer/tv/wrt_renderer_client_tv.h",
 ]
index b73c743d0c5c0b8263349a50adc2fc02058b8502..815788c8424ea68de5ad0ad58d34698f48882dbe 100644 (file)
@@ -358,6 +358,24 @@ bool IsTouchSupported() {
   return is_touch_support.value();
 }
 
+bool IsLiteMemoryBoard() {
+  static absl::optional<bool> is_lite_memory_board;
+  if (is_lite_memory_board.has_value())
+    return is_lite_memory_board.value();
+
+  bool lite_memory = false;
+  if (SYSTEM_INFO_ERROR_NONE !=
+      system_info_get_custom_bool(
+          "com.samsung/featureconf/product.lite_memory.support",
+          &lite_memory)) {
+    LOG(ERROR) << "Fail to get system info: product.lite_memory.support";
+  }
+  LOG(INFO) << "lite_memory : " << lite_memory;
+  is_lite_memory_board = lite_memory;
+
+  return is_lite_memory_board.value();
+}
+
 #endif
 
 }  // namespace wrt
index c62ef568b1a36be9fd62981d4099aaaa703143e6..6aaa6d05bba7e9ff5d358cd26e11a149b99f2993 100644 (file)
@@ -76,6 +76,7 @@ bool IsVisualControllerSupported();
 bool IsMouseCursorSupportedModel();
 bool IsDisplayRotatorSupported();
 bool IsSensorSupported();
+bool IsLiteMemoryBoard();
 #endif
 
 }  // namespace wrt
index 659a9ec2db03643bbceb621ec57b21da6e77ed74..14c9f9f7533f8672b77d0bb97a550594006b815b 100644 (file)
@@ -61,7 +61,7 @@
 #include "wrt/src/common/tv/wrt_lib_wrapper.h"
 
 #if defined(THREAD_BOOSTER_SERVICE)
-#include "services/thread_booster/public/cpp/thread_booster.h"
+#include "wrt/src/common/tv/wrt_thread_booster.h"
 #endif
 
 #if defined(TIZEN_PEPPER_EXTENSIONS)
@@ -323,13 +323,11 @@ void NativeWebRuntimeDelegateTV::EarlyLoadUrlIfHostedApp() {
 
 void NativeWebRuntimeDelegateTV::BoostNetworkServiceThread() {
 #if defined(THREAD_BOOSTER_SERVICE)
-  if (GetCurrentSystemTime() > 120000)
+  if (GetCurrentSystemTime() > (IsLiteMemoryBoard() ? 500000 : 120000))
     return;
 
   LOG(INFO) << "boost NetworkService as RR";
-  thread_booster::BoostThreadByName("NetworkService",
-                                    thread_booster::MediaType::kAudioVideo,
-                                    thread_booster::BoostingLevel::kRealtime);
+  WRT_thread_booster::GetInstance()->RegisterThreadByName("NetworkService");
 #endif
 }
 
index 9affd029605848be6516796318f754e79ea0a6b1..75af01a9da052357954f3bc78cf501105dafd031 100644 (file)
 #include "tizen_src/ewk/efl_integration/eweb_accessibility_util.h"
 #endif
 
+#if defined(THREAD_BOOSTER_SERVICE)
+#include "wrt/src/common/tv/wrt_thread_booster.h"
+#endif
+
 namespace discardable_memory {
 class DiscardableSharedMemoryManager;
 }
@@ -1403,6 +1407,14 @@ void WRTNativeWindowTV::SetPageVisibility(bool visible) {
   else
     VisibilityChangedAsBackground();
 
+#if defined(THREAD_BOOSTER_SERVICE)
+  if (visible) {
+    WRT_thread_booster::GetInstance()->BoostUpRegisteredThreads();
+  } else {
+    WRT_thread_booster::GetInstance()->BoostDownRegisteredThreads();
+  }
+#endif
+
   auto* extension_manager = XWalkExtensionManager::GetInstance();
   extension_manager->NotifyWindowEvent("visibility", visibility_state_);
 
diff --git a/wrt/src/common/tv/wrt_thread_booster.cc b/wrt/src/common/tv/wrt_thread_booster.cc
new file mode 100755 (executable)
index 0000000..b9d1ab5
--- /dev/null
@@ -0,0 +1,61 @@
+// Copyright (c) 2024 Samsung Electronics Co., Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "wrt/src/common/tv/wrt_thread_booster.h"
+
+#include "boost-api.h"
+
+#include "base/logging.h"
+#include "base/synchronization/lock.h"
+
+namespace wrt {
+
+const unsigned int current_pid = getpid();
+boost_generic_info_t generic_info;
+base::Lock thread_list_lock;
+
+// static
+WRT_thread_booster* WRT_thread_booster::GetInstance() {
+  static WRT_thread_booster instance;
+  return &instance;
+}
+
+WRT_thread_booster::WRT_thread_booster() {
+  generic_info.parent.framework_type = BOOST_GENERIC;
+  generic_info.event = BOOST_GENERIC_EVENT_START;
+  generic_info.group = BOOST_CGROUP_NORMAL;
+  generic_info.sched = BOOST_API_SCHED_RR;
+  generic_info.boostingTimeMs = 0;
+}
+
+void WRT_thread_booster::RegisterThreadByName(std::string name) {
+  base::AutoLock lock(thread_list_lock);
+  LOG(INFO) << "register thread : " << name;
+  thread_list_.push_back(name);
+}
+
+void WRT_thread_booster::BoostUpRegisteredThreads() {
+  base::AutoLock lock(thread_list_lock);
+  generic_info.event = BOOST_GENERIC_EVENT_START;
+  LOG(INFO) << "boost up registered all thread!";
+  for (auto value : thread_list_) {
+    LOG(INFO) << "register boost up thread : " << value;
+    boost_request_by_thread_name(current_pid, value.c_str(),
+        (const boost_info_t *)&generic_info);
+  }
+}
+
+void WRT_thread_booster::BoostDownRegisteredThreads() {
+  base::AutoLock lock(thread_list_lock);
+  generic_info.event = BOOST_GENERIC_EVENT_STOP;
+  LOG(INFO) << "boost down registered all thread!";
+  for (auto value : thread_list_) {
+    boost_request_by_thread_name(current_pid, value.c_str(),
+        (const boost_info_t *)&generic_info);
+    LOG(INFO) << "register boost down thread : " << value;
+  }
+
+}
+
+}  // namespace wrt
diff --git a/wrt/src/common/tv/wrt_thread_booster.h b/wrt/src/common/tv/wrt_thread_booster.h
new file mode 100755 (executable)
index 0000000..e7e7528
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright (c) 2024 Samsung Electronics Co., Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMMON_WRT_THREAD_BOOSTER_H_
+#define COMMON_WRT_THREAD_BOOSTER_H_
+
+#include <list>
+#include <string>
+
+namespace wrt {
+
+class WRT_thread_booster {
+ public:
+  static WRT_thread_booster* GetInstance();
+
+  void RegisterThreadByName(std::string name);
+  void BoostUpRegisteredThreads();
+  void BoostDownRegisteredThreads();
+
+
+  WRT_thread_booster();
+  ~WRT_thread_booster() = default;
+
+ private:
+  std::list<std::string> thread_list_;
+};
+
+}  // namespace wrt
+
+#endif  // COMMON_WRT_THREAD_BOOSTER_H_
\ No newline at end of file
index 8fe88360baeb6c4c00817ead5ac8c2e5e6bc828b..4d8af348941f412e47ff781c642b584e03141fb5 100644 (file)
@@ -32,7 +32,8 @@
 #endif
 
 #if defined(THREAD_BOOSTER_SERVICE)
-#include "services/thread_booster/public/cpp/thread_booster.h"
+#include "wrt/src/base/platform_info.h"
+#include "wrt/src/common/tv/wrt_thread_booster.h"
 #endif
 
 namespace wrt {
@@ -152,18 +153,18 @@ unsigned long long GetCurrentSystemTime() {
 }
 
 void BoosRendererThreads() {
-  if (GetCurrentSystemTime() > 120000)
+  if (GetCurrentSystemTime() > (IsLiteMemoryBoard() ? 500000 : 120000))
     return;
 
 #if defined(THREAD_BOOSTER_SERVICE)
   LOG(INFO) << "boost Renderer/GPU threads as RR";
-  thread_booster::BoostThreadByName("Chrome_InProcRendererThread",
-                                    thread_booster::MediaType::kAudioVideo,
-                                    thread_booster::BoostingLevel::kRealtime);
-
-  thread_booster::BoostThreadByName("Chrome_InProcGpuThread",
-                                    thread_booster::MediaType::kAudioVideo,
-                                    thread_booster::BoostingLevel::kRealtime);
+  WRT_thread_booster::GetInstance()->RegisterThreadByName("Chrome_InProcRe");
+  WRT_thread_booster::GetInstance()->RegisterThreadByName("Chrome_InProcGp");
+  if (IsLiteMemoryBoard()) {
+    LOG(INFO) << "boost Compositor threads as RR (LiteMemory Model)";
+    WRT_thread_booster::GetInstance()->RegisterThreadByName("VizCompositorTh");
+    WRT_thread_booster::GetInstance()->RegisterThreadByName("Compositor");
+  }
 #endif
 }