AI 中文总结
研究针对安卓系统中优先级反转致延迟关键线程阻塞问题,提出SuperPass轻量级内核机制,通过快速调度低优先级阻塞线程减轻反转,经实验评估,该机制有效减少阻塞时间和次数,降低卡顿帧,性能优于现有方法。
AI 中文摘要
优先级反转是指高优先级线程被低优先级线程延迟的情况。虽然在实时系统中已被充分研究,但在通用操作系统(如安卓)中的影响仍未得到充分理解。在安卓系统中,优先级反转频繁发生,会延迟对延迟敏感的线程,影响用户体验。例如,前台应用的UI线程常被低优先级线程阻塞,阻塞时长可达210毫秒。为解决此问题,研究发现长阻塞主要源于低优先级阻塞线程的累积CPU等待时间,而非关键段延迟,且追踪有限数量的延迟关键线程即可实现良好响应性且开销低。基于此,提出SuperPass,一种轻量级内核机制,通过对阻塞延迟关键线程的低优先级线程进行快速调度来减轻优先级反转。它引入调度器快速通道,授予阻塞延迟关键线程的线程立即访问CPU的权限,并采用锁级检测器有效识别此类阻塞线程。在谷歌Pixel 8智能手机上进行评估,以UI线程为例,SuperPass与默认调度器相比,平均将第99.9百分位阻塞持续时间减少72.0%,阻塞次数减少47.7%,并将卡顿帧减少29.2%,系统范围的CPU开销仅为0.74%。SuperPass还优于现有方法,包括优先级继承、实时UI提升和代理执行。
英文摘要
Priority inversion occurs when a high-priority thread is delayed by a lower-priority one. Although well studied in real-time systems, its impact in general-purpose OSes (e.g., Android) remains underexplored. On Android, we find that priority inversions happen frequently and can delay latency-critical threads, degrading user experience. For example, the foreground app's UI thread is frequently blocked by low-priority threads, with blocking durations of up to 210 ms, enough to cause dropped frames. Existing solutions designed for real-time systems fail to eliminate long priority-inversion blockings on latency-critical threads and may introduce high overhead on Android. To solve this problem, we uncover two insights on Android: 1) long blockings are mainly due to the accumulated CPU waiting time of low-priority blocking threads rather than their critical-section latency; and 2) although latency-critical threads can be blocked by many concurrent readers, tracking a limited number of them is sufficient to achieve good responsiveness with low overhead in most cases. Guided by these insights, we propose SuperPass, a lightweight kernel mechanism that mitigates priority inversion by fast-track scheduling of low-priority threads blocking latency-critical threads. It introduces a scheduler fast track that grants immediate CPU access to threads blocking latency-critical threads, and employs a lock-level detector that effectively identifies most such blocking threads. We evaluate SuperPass on a Google Pixel 8 smartphone. Taking UI thread as a case study, SuperPass decreases the 99.9th-percentile blocking duration by 72.0% and blocking count by 47.7% on average compared to the default scheduler, and reduces janky frames by 29.2% with a system-wide CPU overhead of only 0.74%. SuperPass also outperforms existing approaches including priority inheritance, real-time UI promotion, and Proxy Execution.