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

Commit f5aa888

Browse files
[CP][engine] reland weaken affinity of raster/ui to non-e core instead of only fast core (#54842)
� only fast core (#54616) Some android devices have only a single fast core. We set the threading affinity for UI/Raster to the fast core, which can lead to the UI/Raster being serialized on this thread. Instead, we should weaken /invert the affinity to "Not slow cores". FIxes flutter/flutter#153690 Customer money will see some benchmark regressions but they can deal.
1 parent a6bd3f1 commit f5aa888

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

fml/cpu_affinity.cc

Lines changed: 4 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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)