SystemUI: Implement IntrinsicLockDispatcher for background tasks
- This commit refactors the background coroutine dispatcher in SystemUI to utilize a new, custom IntrinsicLockDispatcher. - Previously, newFixedThreadPoolContext was used which internally uses ScheduledThreadPoolExecutor, that has been found to cause unintended waiting on the main thread, during background work and poor scheduling decisions. This was due to its reliance on a single internal ReentrantLock for all queue operations, leading to lock contention. - This new dispatcher uses a ThreadPoolExecutor paired with a custom, ReentrantLock-free SynchronizedLinkedBlockingQueue. This queue uses intrinsic monitor locks (synchronized) to mitigate contention between worker threads and task-submitting threads. - Improvements: A shell script was written to unlock, drag the shade, dismiss the shade and relock the device. During this, a perfetto trace was captured with the flag on and off, both across multiple iterations. The following improvements were seen in regards to stall durations (decrease is good): - Mean duration decreased by 5.97% - Peak duration decreased by 25.96% - Sum duration decreased by 24.77% - Trough duration slightly increased by 0.97% Flag: com.android.systemui.sysui_intrinsic_lock_dispatcher Test: Manual Bug: 419472502 Change-Id: I0585c354311b1e7abec908de85265dd0a62e2764
Loading
Please register or sign in to comment