Superpack: Pushing the limits of compression in Facebook’s mobile apps

Managing app size at Facebook is a unique challenge: Every day, developers check in large volumes of code, and each line of code translates into additional bits in the apps that people ultimately d…

Sapan Bhatia
15 min readintermediate
--
View Original

Overview

The article discusses Superpack, a compression technique developed by Facebook to manage app size in mobile applications. By combining compiler analysis with data compression, Superpack achieves over 20% size reduction compared to traditional Android APK compression methods, significantly improving download speeds and reducing bandwidth usage for users worldwide.

What You'll Learn

1

How to leverage compiler techniques to improve data compression

2

Why Superpack achieves better compression ratios than traditional tools

3

How to apply hierarchical compression for optimized LZ parsing

Prerequisites & Requirements

  • Understanding of data compression techniques and compiler theory
  • Familiarity with compression tools like Zip and Xz(optional)

Key Questions Answered

How does Superpack improve compression ratios for mobile apps?
Superpack combines compiler analysis with data compression techniques to enhance LZ parsing and entropy coding, achieving over 20% better compression ratios compared to traditional methods like Zip. This approach allows for longer repeating sequences and better context-aware coding, which significantly reduces app size.
What types of data does Superpack target for compression?
Superpack specifically targets Dex bytecode, ARM machine code, and Hermes bytecode. Each format utilizes a tailored set of compression transforms that leverage the syntax and grammar of the code to maximize compression efficiency.
What are the limitations of Superpack in terms of compression speed?
Superpack is designed as an asymmetric compressor, allowing for fast decompression but slower compression speeds. This makes it unsuitable for streaming compression, as it cannot keep up with modern data transfer rates, particularly for real-time applications.
Why is Superpack not currently suitable for image or video files?
Superpack is optimized for structured data and code, which means it does not target unstructured formats like images, video, or sound files. Its design focuses on leveraging compiler techniques that are not applicable to these types of data.

Key Statistics & Figures

Average size savings with Superpack
over 20 percent
Compared to Android's default Zip compression for mobile apps.

Technologies & Tools

Compression Tool
Superpack
Used to compress mobile application data for Facebook's Android apps.
Tool
Z3 Smt Solver
Utilized for automated parsing and restructuring of code formats.

Key Actionable Insights

1
Implementing Superpack can significantly reduce the size of mobile applications, leading to faster downloads and lower data costs for users.
This is particularly beneficial in regions with limited bandwidth, where app size directly impacts user experience and accessibility.
2
Utilizing compiler techniques in data compression can unlock new optimization opportunities that traditional methods may overlook.
By understanding the structure of the data being compressed, engineers can achieve better performance and efficiency in their applications.
3
Consider the trade-offs between compression speed and decompression efficiency when integrating Superpack into your workflow.
While Superpack excels at reducing app size, its slower compression speed may not be suitable for all use cases, especially those requiring real-time data processing.

Common Pitfalls

1
Assuming that Superpack can be used for all types of data without considering its design limitations.
Superpack is optimized for structured data and code, making it ineffective for unstructured formats like images or videos. Understanding its intended use cases is crucial for effective implementation.

Related Concepts

Data Compression Techniques
Compiler Theory
Lempel-ziv Parsing
Entropy Coding