Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: base/threading/platform_thread_android.cc

Issue 1616953003: content: Improve thread priority for raster threads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/chrome_restart_request.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/threading/platform_thread.h" 5 #include "base/threading/platform_thread.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <sys/prctl.h> 9 #include <sys/prctl.h>
10 #include <sys/resource.h> 10 #include <sys/resource.h>
11 #include <sys/types.h> 11 #include <sys/types.h>
12 #include <unistd.h> 12 #include <unistd.h>
13 13
14 #include "base/android/jni_android.h" 14 #include "base/android/jni_android.h"
15 #include "base/android/thread_utils.h" 15 #include "base/android/thread_utils.h"
16 #include "base/lazy_instance.h" 16 #include "base/lazy_instance.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/threading/platform_thread_internal_posix.h" 18 #include "base/threading/platform_thread_internal_posix.h"
19 #include "base/threading/thread_id_name_manager.h" 19 #include "base/threading/thread_id_name_manager.h"
20 #include "base/tracked_objects.h" 20 #include "base/tracked_objects.h"
21 #include "jni/ThreadUtils_jni.h" 21 #include "jni/ThreadUtils_jni.h"
22 22
23 namespace base { 23 namespace base {
24 24
25 namespace internal { 25 namespace internal {
26 26
27 // - BACKGROUND is 9 due to it being the nicest value we can use that's still 27 // - BACKGROUND corresponds to Android's PRIORITY_BACKGROUND = 10 value and can
28 // above an Android system threshold that enables heavy throttling starting at 28 // result in heavy throttling.
29 // 10; we want to be lower-priority than Chrome's other threads without
30 // incurring this behavior.
31 // - DISPLAY is -6 due to being midway between Android's DISPLAY (-4) and 29 // - DISPLAY is -6 due to being midway between Android's DISPLAY (-4) and
32 // URGENT_DISPLAY (-8). 30 // URGENT_DISPLAY (-8).
reveman 2016/02/12 05:56:44 Seems like a bit of an abuse to take URGENT_DISPLA
aelias_OOO_until_Jul13 2016/02/23 23:01:40 Yeah, it seems a bit weird. This was introduced i
reveman 2016/02/24 17:08:53 Created a separate patch for this: https://coderev
33 // - REALTIME_AUDIO corresponds to Android's THREAD_PRIORITY_AUDIO = -16 value. 31 // - REALTIME_AUDIO corresponds to Android's PRIORITY_AUDIO = -16 value.
34 const ThreadPriorityToNiceValuePair kThreadPriorityToNiceValueMap[4] = { 32 const ThreadPriorityToNiceValuePair kThreadPriorityToNiceValueMap[4] = {
35 {ThreadPriority::BACKGROUND, 9}, 33 {ThreadPriority::BACKGROUND, 10},
reveman 2016/02/12 05:56:44 Note that this will also make the renderer main th
aelias_OOO_until_Jul13 2016/02/23 23:01:40 Yeah, that's concerning. I don't think we want to
reveman 2016/02/24 17:08:54 Removed it as part of this patch.
36 {ThreadPriority::NORMAL, 0}, 34 {ThreadPriority::NORMAL, 0},
37 {ThreadPriority::DISPLAY, -6}, 35 {ThreadPriority::DISPLAY, -6},
38 {ThreadPriority::REALTIME_AUDIO, -16}, 36 {ThreadPriority::REALTIME_AUDIO, -16},
39 }; 37 };
40 38
41 bool SetCurrentThreadPriorityForPlatform(ThreadPriority priority) { 39 bool SetCurrentThreadPriorityForPlatform(ThreadPriority priority) {
42 // On Android, we set the Audio priority through JNI as Audio priority 40 // On Android, we set the Audio priority through JNI as Audio priority
43 // will also allow the process to run while it is backgrounded. 41 // will also allow the process to run while it is backgrounded.
44 if (priority == ThreadPriority::REALTIME_AUDIO) { 42 if (priority == ThreadPriority::REALTIME_AUDIO) {
45 JNIEnv* env = base::android::AttachCurrentThread(); 43 JNIEnv* env = base::android::AttachCurrentThread();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // 1Mb is not enough for some tests (see http://crbug.com/263749 for example). 94 // 1Mb is not enough for some tests (see http://crbug.com/263749 for example).
97 return 2 * (1 << 20); // 2Mb 95 return 2 * (1 << 20); // 2Mb
98 #endif 96 #endif
99 } 97 }
100 98
101 bool RegisterThreadUtils(JNIEnv* env) { 99 bool RegisterThreadUtils(JNIEnv* env) {
102 return RegisterNativesImpl(env); 100 return RegisterNativesImpl(env);
103 } 101 }
104 102
105 } // namespace base 103 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/chrome_restart_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698