OLX Mootaz Ltaief Jun 24, 2019

Android Jetpack Benchmark: JSON Parser Performance

Article Summary

Mootaz Ltaief from OLX Engineering put four popular Android JSON parsers head-to-head using Jetpack Benchmark. The results reveal a brutal tradeoff: the fastest parser costs you 1.1 MB of app size.

When OLX slashed their Android app from 23 MB to 11 MB, they discovered Jackson was consuming 1.1 MB alone. This sparked a systematic benchmark of Gson, Moshi, Jackson, and Kotlinx.Serialization using Google's new Benchmark library on a lower-end Huawei Y7 device representing their core userbase.

Key Takeaways

Critical Insight

For Android apps targeting emerging markets or size-conscious builds, Kotlinx.Serialization offers the best balance of speed and footprint, running close to Jackson's performance at a fraction of the size cost.

The article includes the exact benchmark setup and a link to the full source code so you can run these tests on your own JSON payloads and devices.

About This Article

Problem

OLX's Android app grew to 23 MB even after optimization attempts. The Jackson library alone took up 1.1 MB, and the compiled APK contained over 10,000 methods.

Solution

Mootaz Ltaief tested four JSON serialization libraries using Google's Jetpack Benchmark library (v1.0.0-alpha02). The tests ran on a Huawei Y7 device with Android 7.0 to measure both speed and file size.

Impact

Kotlinx.Serialization matched Jackson's performance while using much less space. This let OLX shrink the app size without losing parsing speed on lower-end devices.