Android Developers Blog Feb 17, 2026

Under the Hood: Android 17's Lock-Free MessageQueue

Article Summary

Shai Barack and Charles Munger from Android reveal how a 20-year-old lock in MessageQueue was secretly causing UI jank across the entire Android ecosystem. Their solution? A lock-free data structure that's up to 5,000x faster.

Android 17 replaces MessageQueue with DeliQueue, a lock-free implementation that eliminates priority inversion issues. The Android Platform Performance team used Perfetto traces from millions of devices to confirm that MessageQueue lock contention was a systemic problem causing dropped frames and startup delays across apps.

Key Takeaways

Critical Insight

Android 17's lock-free MessageQueue cuts app jank by 4% and startup time by 9.1% by eliminating priority inversion through a novel Treiber stack and min-heap hybrid.

The article includes working code examples and shows how to use PerfettoSQL to find MessageQueue contention patterns in your own trace data.

About This Article

Problem

MessageQueue used a single monitor lock that caused priority inversion. Low-priority background threads would block the high-priority UI thread. Perfetto traces showed an 18ms block that went over the 16ms frame deadline needed for 60Hz rendering.

Solution

Engineers built DeliQueue, a hybrid lock-free data structure that combines a Treiber stack for concurrent message insertion with a single-threaded min-heap for ordering. It uses atomic Compare-And-Swap operations and tombstoning to remove messages safely without needing global locks.

Impact

Synthetic benchmarks showed multi-threaded insertions were up to 5,000x faster than the old MessageQueue. Real-world testing on internal beta devices found a 15% reduction in main thread lock contention time and a 9.1% improvement in app startup time at the 95th percentile.

Recent from Android Developers Blog

Related Articles