[engine] reland weaken affinity of raster/ui to non-e core instead of only fast core (flutter/engine#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 https://github.com/flutter/flutter/issues/153690 Customer money will see some benchmark regressions but they can deal.
This commit is contained in:
parent
aa26fa1254
commit
248dfb2334
@ -58,6 +58,8 @@ CPUSpeedTracker::CPUSpeedTracker(std::vector<CpuIndexAndSpeed> data)
|
|||||||
}
|
}
|
||||||
if (data.speed == min_speed_value) {
|
if (data.speed == min_speed_value) {
|
||||||
efficiency_.push_back(data.index);
|
efficiency_.push_back(data.index);
|
||||||
|
} else {
|
||||||
|
not_efficiency_.push_back(data.index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,6 +79,8 @@ const std::vector<size_t>& CPUSpeedTracker::GetIndices(
|
|||||||
return efficiency_;
|
return efficiency_;
|
||||||
case CpuAffinity::kNotPerformance:
|
case CpuAffinity::kNotPerformance:
|
||||||
return not_performance_;
|
return not_performance_;
|
||||||
|
case CpuAffinity::kNotEfficiency:
|
||||||
|
return not_efficiency_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,9 @@ enum class CpuAffinity {
|
|||||||
|
|
||||||
/// @brief Request affinity for all non-performance cores.
|
/// @brief Request affinity for all non-performance cores.
|
||||||
kNotPerformance,
|
kNotPerformance,
|
||||||
|
|
||||||
|
/// @brief Request affinity for all non-efficiency cores.
|
||||||
|
kNotEfficiency,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief Request count of efficiency cores.
|
/// @brief Request count of efficiency cores.
|
||||||
@ -79,6 +82,7 @@ class CPUSpeedTracker {
|
|||||||
std::vector<size_t> efficiency_;
|
std::vector<size_t> efficiency_;
|
||||||
std::vector<size_t> performance_;
|
std::vector<size_t> performance_;
|
||||||
std::vector<size_t> not_performance_;
|
std::vector<size_t> not_performance_;
|
||||||
|
std::vector<size_t> not_efficiency_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @note Visible for testing.
|
/// @note Visible for testing.
|
||||||
|
@ -29,6 +29,9 @@ TEST(CpuAffinity, NormalSlowMedFastCores) {
|
|||||||
ASSERT_EQ(tracker.GetIndices(CpuAffinity::kNotPerformance).size(), 2u);
|
ASSERT_EQ(tracker.GetIndices(CpuAffinity::kNotPerformance).size(), 2u);
|
||||||
ASSERT_EQ(tracker.GetIndices(CpuAffinity::kNotPerformance)[0], 0u);
|
ASSERT_EQ(tracker.GetIndices(CpuAffinity::kNotPerformance)[0], 0u);
|
||||||
ASSERT_EQ(tracker.GetIndices(CpuAffinity::kNotPerformance)[1], 1u);
|
ASSERT_EQ(tracker.GetIndices(CpuAffinity::kNotPerformance)[1], 1u);
|
||||||
|
ASSERT_EQ(tracker.GetIndices(CpuAffinity::kNotEfficiency).size(), 2u);
|
||||||
|
ASSERT_EQ(tracker.GetIndices(CpuAffinity::kNotEfficiency)[0], 1u);
|
||||||
|
ASSERT_EQ(tracker.GetIndices(CpuAffinity::kNotEfficiency)[1], 2u);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CpuAffinity, NoCpuData) {
|
TEST(CpuAffinity, NoCpuData) {
|
||||||
|
@ -49,14 +49,14 @@ static void AndroidPlatformThreadConfigSetter(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case fml::Thread::ThreadPriority::kDisplay: {
|
case fml::Thread::ThreadPriority::kDisplay: {
|
||||||
fml::RequestAffinity(fml::CpuAffinity::kPerformance);
|
fml::RequestAffinity(fml::CpuAffinity::kNotEfficiency);
|
||||||
if (::setpriority(PRIO_PROCESS, 0, -1) != 0) {
|
if (::setpriority(PRIO_PROCESS, 0, -1) != 0) {
|
||||||
FML_LOG(ERROR) << "Failed to set UI task runner priority";
|
FML_LOG(ERROR) << "Failed to set UI task runner priority";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case fml::Thread::ThreadPriority::kRaster: {
|
case fml::Thread::ThreadPriority::kRaster: {
|
||||||
fml::RequestAffinity(fml::CpuAffinity::kPerformance);
|
fml::RequestAffinity(fml::CpuAffinity::kNotEfficiency);
|
||||||
// Android describes -8 as "most important display threads, for
|
// Android describes -8 as "most important display threads, for
|
||||||
// compositing the screen and retrieving input events". Conservatively
|
// compositing the screen and retrieving input events". Conservatively
|
||||||
// set the raster thread to slightly lower priority than it.
|
// set the raster thread to slightly lower priority than it.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user