Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 926b292

Browse files
Widen CPU affinity set. (#53136)
For devices with 1 fast core, the current affinity set is less idea because it forces UI and raster on the same thread. Widen this to exclude slow cores instead of including only the fast core.
1 parent 60a7bb2 commit 926b292

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

fml/cpu_affinity.cc

+4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ CPUSpeedTracker::CPUSpeedTracker(std::vector<CpuIndexAndSpeed> data)
5858
}
5959
if (data.speed == min_speed_value) {
6060
efficiency_.push_back(data.index);
61+
} else {
62+
not_efficiency_.push_back(data.index);
6163
}
6264
}
6365

@@ -77,6 +79,8 @@ const std::vector<size_t>& CPUSpeedTracker::GetIndices(
7779
return efficiency_;
7880
case CpuAffinity::kNotPerformance:
7981
return not_performance_;
82+
case CpuAffinity::kNotEfficiency:
83+
return not_efficiency_;
8084
}
8185
}
8286

fml/cpu_affinity.h

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ enum class CpuAffinity {
2626

2727
/// @brief Request affinity for all non-performance cores.
2828
kNotPerformance,
29+
30+
/// @brief Request affinity for all non-efficiency cores.
31+
kNotEfficiency,
2932
};
3033

3134
/// @brief Request count of efficiency cores.
@@ -79,6 +82,7 @@ class CPUSpeedTracker {
7982
std::vector<size_t> efficiency_;
8083
std::vector<size_t> performance_;
8184
std::vector<size_t> not_performance_;
85+
std::vector<size_t> not_efficiency_;
8286
};
8387

8488
/// @note Visible for testing.

fml/cpu_affinity_unittests.cc

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ TEST(CpuAffinity, NormalSlowMedFastCores) {
2929
ASSERT_EQ(tracker.GetIndices(CpuAffinity::kNotPerformance).size(), 2u);
3030
ASSERT_EQ(tracker.GetIndices(CpuAffinity::kNotPerformance)[0], 0u);
3131
ASSERT_EQ(tracker.GetIndices(CpuAffinity::kNotPerformance)[1], 1u);
32+
ASSERT_EQ(tracker.GetIndices(CpuAffinity::kNotEfficiency).size(), 2u);
33+
ASSERT_EQ(tracker.GetIndices(CpuAffinity::kNotEfficiency)[0], 1u);
34+
ASSERT_EQ(tracker.GetIndices(CpuAffinity::kNotEfficiency)[1], 2u);
3235
}
3336

3437
TEST(CpuAffinity, NoCpuData) {

shell/platform/android/android_shell_holder.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ static void AndroidPlatformThreadConfigSetter(
4949
break;
5050
}
5151
case fml::Thread::ThreadPriority::kDisplay: {
52-
fml::RequestAffinity(fml::CpuAffinity::kPerformance);
52+
fml::RequestAffinity(fml::CpuAffinity::kNotEfficiency);
5353
if (::setpriority(PRIO_PROCESS, 0, -1) != 0) {
5454
FML_LOG(ERROR) << "Failed to set UI task runner priority";
5555
}
5656
break;
5757
}
5858
case fml::Thread::ThreadPriority::kRaster: {
59-
fml::RequestAffinity(fml::CpuAffinity::kPerformance);
59+
fml::RequestAffinity(fml::CpuAffinity::kNotEfficiency);
6060
// Android describes -8 as "most important display threads, for
6161
// compositing the screen and retrieving input events". Conservatively
6262
// set the raster thread to slightly lower priority than it.

0 commit comments

Comments
 (0)