From a7190fd1591ba057e7427441a78b36ec5da39aef Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Fri, 21 Apr 2017 14:30:18 +0100 Subject: [PATCH] Lower profiler saver thread priority. 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 (cherry picked from commit c84073db8e919a000cdb923f34697fd5f17a1b30) --- runtime/jit/profile_saver.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/runtime/jit/profile_saver.cc b/runtime/jit/profile_saver.cc index e2bd1cbc3..60f7b6e04 100644 --- a/runtime/jit/profile_saver.cc +++ b/runtime/jit/profile_saver.cc @@ -16,6 +16,7 @@ #include "profile_saver.h" +#include #include #include #include @@ -431,6 +432,16 @@ void ProfileSaver::Start(const ProfileSaverOptions& options, pthread_create, (&profiler_pthread_, nullptr, &RunProfileSaverThread, reinterpret_cast(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) { -- 2.11.0