Change usleep time from 2 ms to 10 ms 69/318269/2
authorTomasz Swierczek <t.swierczek@samsung.com>
Thu, 26 Sep 2024 06:46:09 +0000 (08:46 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Fri, 27 Sep 2024 10:27:36 +0000 (12:27 +0200)
Apparently, the longer the sleep, less CPU time is used in heavy-load scenarios.

Change-Id: I79b89303eb14a74e699b7ba2e2980dd499dcb781

src/client/client-security-manager.cpp

index fb5cb2c1a469118df230788eac32d1905ee8d6bb..d1fe345c136a53db1fa1e5f0e0371faea96321ed 100644 (file)
@@ -88,8 +88,8 @@ static std::map<enum lib_retcode, std::string> lib_retcode_string_map = {
 };
 
 // variables & definitions for thread security attributes
-#define MAX_SIG_WAIT_TIME   10000 // times 2 ms thats 20 seconds
-#define SLEEP_CONST         2000  // 2 ms
+#define MAX_SIG_WAIT_TIME   2000 // times 10 ms thats 20 seconds
+#define SLEEP_CONST         10000  // 10 ms
 
 // Hackish, based on glibc's definition in sysdeps/unix/sysv/linux/nptl-signals.h
 #define SIGSETXID           (__SIGRTMIN + 1)
@@ -692,7 +692,7 @@ static inline int security_manager_sync_threads_internal(const std::string &app_
                         }
 
                         LogWarning("Received EAGAIN from tgkill, wait a bit & try again");
-                        usleep(SLEEP_CONST);   // 2 ms
+                        usleep(SLEEP_CONST);   // 10 ms
                         continue;
                     } else if (ESRCH == err) { // thread already gone - noop
                         break;
@@ -704,7 +704,7 @@ static inline int security_manager_sync_threads_internal(const std::string &app_
             }
         }
 
-        usleep(SLEEP_CONST);   // 2 ms
+        usleep(SLEEP_CONST);   // 10 ms
         --time_left;
 
         // break if number of threads in waiting state equals to number of alive tids minus current one
@@ -743,7 +743,7 @@ static inline int security_manager_sync_threads_internal(const std::string &app_
         ready_tids = count_alive_tids_with_state(2, current_tids);
         if (ready_tids == (int)current_tids.size())
             break;
-        usleep(SLEEP_CONST);   // 2 ms
+        usleep(SLEEP_CONST);   // 10 ms
         if (i % 500 == 0)
             LogWarning("Still waiting for threads to finalize handlers... completed by: " << ready_tids
                                                                                           << ", all tids managed now: "