Set CPU boosting for executing lux 29/318029/2
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 24 Sep 2024 01:46:41 +0000 (10:46 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 24 Sep 2024 01:48:39 +0000 (10:48 +0900)
To improve launching performance of lux, this patch adds setting CPU
boosting to lux.

Change-Id: I1f209dd41aec7b8d68106b04d42c9c842b907863
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/launchpad-process-pool/lux_manager.cc
src/lux/src/lux/mod.rs

index f3c885003fea25f5d9caf49bd3ebd27db5fb5c9b..946f8ff045d7185ad7eb57eb6eea4931edd0adb1 100644 (file)
@@ -20,6 +20,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 
+#include <cpu_boost_controller.hh>
 #include <exception.hh>
 #include <socket.hh>
 #include <peer_credentials.hh>
@@ -213,6 +214,8 @@ void LuxManager::OnIOEventReceived(int fd, int condition) {
 }
 
 void LuxManager::OnExecution() {
+  CPUBoostController::DoBoost(getpid(), CPUBoostController::Level::Strong, -1,
+                              true);
   std::vector<int> except_fds{read_socket_->GetFd(), write_socket_->GetFd(),
                               sigchld_socket_->GetFd()};
   Util::CloseAllFds(except_fds);
index 8f2aa38d5b1b768f1c54f69871e9624ec85a8168..a50a5da496ac4a08056a708ca30fd3c8e4489313 100644 (file)
@@ -9,6 +9,7 @@ mod sigchld_manager;
 use glib_sys::*;
 use libc::*;
 use std::mem;
+use std::process;
 use tizen_bundle::*;
 use tizen_parcel::*;
 
@@ -32,6 +33,18 @@ extern "C" {
     fn security_manager_prepare_app_candidate() -> c_int;
 }
 
+#[repr(C)]
+pub struct ResourcePidInfo {
+    pid: c_int,
+    tid: *mut c_int,
+    tid_count: c_int,
+}
+
+#[link(name = "capi-system-resource")]
+extern "C" {
+    fn resource_clear_cpu_boosting(pid: ResourcePidInfo) -> c_int;
+}
+
 pub struct Lux {
     mainloop: *mut GMainLoop,
     app_labels_monitor: AppLabelsMonitor,
@@ -111,6 +124,7 @@ impl Lux {
         }
 
         self.app_labels_monitor.init();
+        self.clear_boosting();
         unsafe { g_main_loop_run(self.mainloop) }
         self.app_labels_monitor.dispose();
         Ok(())
@@ -214,4 +228,14 @@ impl Lux {
 
         Ok(())
     }
+
+    fn clear_boosting(&self) {
+        let mut pid: c_int = process::id() as c_int;
+        let mut resource_pid = ResourcePidInfo {
+            pid: 0,
+            tid: &mut pid,
+            tid_count: 1,
+        };
+        unsafe { resource_clear_cpu_boosting(resource_pid); }
+    }
 }