Android Developers Blog Shai Barack

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

This article covers Android 17 Android 17 release notes

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.

Continue reading

What This Article Covers

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.

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

This page summarizes “Under the Hood: Android 17's Lock-Free MessageQueue” by Android Developers Blog, published Feb 17, 2026. All credit for the original work goes to the authors.

Read the original on android-developers.googleblog.com (opens in new tab)

AI tools for Android

Browse all AI tools →