Use PerformanceHintManager on Android for main thread and stylo thread pool threads
Categories
(Core :: Performance Engineering, task)
Tracking
()
Tracking | Status | |
---|---|---|
firefox118 | --- | fixed |
People
(Reporter: jnicol, Assigned: jnicol)
References
(Blocks 1 open bug)
Details
(Keywords: perf-alert, Whiteboard: [sp3])
Attachments
(3 files)
We have been experimenting with PerformanceHintManager on Android. This is a fairly recent API that allows you to specify a target work duration for a set of threads. You continually report the actual work duration, and the system will schedule the threads appropriately in order to hit the target. This makes better use of the powerful cores on heterogenous CPUs, which we've seen to be an issue with the stylo thread pool on Android (see bug 1834977).
From testing this API only appears to make a difference on my Pixel 6 and Pixel 7 devices. On other devices createHintSession()
API call either returns null, or it returns an object but the scheduling does not appear to be affected in any way. The Pixel implementation can be found here. It appears to make use of Linux's "Util Clamp" feature.
Despite unfortunately not having an effect on most devices, on the devices where it does work it appears to be an unequivocal win, increasing the speedometer score on my Pixel 7 from ~6.3 to ~6.8. We should therefore use it when available. For other devices we may want to find an alternative solution such as manually setting the CPU affinity of these threads, but the right approach there is a bit less obvious so let's do that in a follow up.
Assignee | ||
Comment 1•1 years ago
|
||
On Unix platforms this is a pthread_t, and on windows it is a HANDLE.
Updated•1 years ago
|
Assignee | ||
Comment 2•1 years ago
|
||
PerformanceHintManager is an Android API that allows the caller to
create a PerformanceHintSession, representing a workload shared by a
group of threads that should be completed within a target duration
each cycle. The actual duration spent working is reported each cycle,
and the system can then adjust scheduling of the threads accordingly
in order to hit the target going forward.
This patch adds the API to HAL along with an Android
implementation (and a nop fallback implementation for other
platforms).
Depends on D186237
Assignee | ||
Comment 3•1 years ago
|
||
On Android devices with heterogeneous CPUs we often see the main
thread, and even more frequently the stylo threadpool threads, being
scheduled on devices' little cores even when there is plenty of work
to do. This patch uses the PerformanceHintManager API to help the
system schedule these threads more intelligently.
When VsyncRefreshDriverTimer is started, we create a
PerformanceHintSession for the main thread and stylo threadpool
threads, with a (fairly arbitrary) target duration of half the refresh
period. Each tick we report the actual duration spent. 500ms after the
timer is stopped we destroy the session, unless the timer has been
restarted again.
Depends on D186238
Updated•1 years ago
|
Updated•1 years ago
|
Updated•1 years ago
|
Updated•1 years ago
|
Updated•1 years ago
|
Comment 5•1 years ago
|
||
Backed out 3 changesets (Bug 1848766) for causing build bustage at AndroidPerformanceHintManager.cpp
Backout: https://hg.mozilla.org/integration/autoland/rev/dc30e1edb840c11a63568d4ca9041fe7f08b3740
Failure log: https://treeherder.mozilla.org/logviewer?job_id=426463497&repo=autoland&lineNumber=17142
Assignee | ||
Comment 6•1 years ago
|
||
Sorry, moved some code around which caused an unused function warning in 32 bit android builds. moved it back so should work now
Updated•1 years ago
|
Comment 8•1 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/9a102218c667
https://hg.mozilla.org/mozilla-central/rev/99fee20f2c11
https://hg.mozilla.org/mozilla-central/rev/b53328c9eece
Comment 9•1 years ago
|
||
(In reply to Pulsebot from comment #7)
Pushed by jnicol@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/9a102218c667
Add API to get stylo threadpool thread handles. r=emilio
https://hg.mozilla.org/integration/autoland/rev/99fee20f2c11
Add PerformanceHintManager implementation to HAL.
r=smaug,emilio,geckoview-reviewers,owlish
https://hg.mozilla.org/integration/autoland/rev/b53328c9eece
Use PerformanceHintManager for main thread and stylo threads in
VsyncRefreshDriverTimer. r=smaug
== Change summary for alert #39370 (as of Tue, 22 Aug 2023 15:37:55 GMT) ==
Improvements:
Ratio | Test | Platform | Options | Absolute values (old vs new) |
---|---|---|---|---|
4% | cross_origin_pageload | windows10-64-shippable-qr | e10s fission stylo webrender | 275.40 -> 265.65 |
3% | cross_origin_pageload | windows10-64-shippable-qr | e10s fission stylo webrender-sw | 276.34 -> 266.89 |
For up to date results, see: https://treeherder.mozilla.org/perfherder/alerts?id=39370
Updated•1 years ago
|
Assignee | ||
Comment 10•1 years ago
|
||
The perf alert is somewhat unexpected, could it be from another change instead? This patch mostly does nothing on non-Android (and in fact not even on the Android devices we have in CI!). I think the only change it should have made is that we may spawn the stylo threads sooner.
Description
•