OSDN Git Service

Lower profiler saver thread priority.
authorNicolas Geoffray <ngeoffray@google.com>
Fri, 21 Apr 2017 13:30:18 +0000 (14:30 +0100)
committerNarayan Kamath <narayan@google.com>
Mon, 24 Apr 2017 15:54:45 +0000 (16:54 +0100)
Spotted while looking at bug reports. Doesn't hurt, and better
be safe than sorry.

bug:37446669
bug:36631902
test:manual, looking at bugreports

(cherry picked from commit 23caed84eba735b2615f5962b5161f6dc9e8bd4e)

Change-Id: I47723e368f3a7d863a9ed2e85c223e6e242508d5

runtime/jit/profile_saver.cc

index e2bd1cb..60f7b6e 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "profile_saver.h"
 
+#include <sys/resource.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -431,6 +432,16 @@ void ProfileSaver::Start(const ProfileSaverOptions& options,
       pthread_create,
       (&profiler_pthread_, nullptr, &RunProfileSaverThread, reinterpret_cast<void*>(instance_)),
       "Profile saver thread");
+
+#if defined(ART_TARGET_ANDROID)
+  // At what priority to schedule the saver threads. 9 is the lowest foreground priority on device.
+  static constexpr int kProfileSaverPthreadPriority = 9;
+  int result = setpriority(
+      PRIO_PROCESS, pthread_gettid_np(profiler_pthread_), kProfileSaverPthreadPriority);
+  if (result != 0) {
+    PLOG(ERROR) << "Failed to setpriority to :" << kProfileSaverPthreadPriority;
+  }
+#endif
 }
 
 void ProfileSaver::Stop(bool dump_info) {