Project LightSpeed: Rewriting the Messenger codebase for a faster, smaller, and simpler messaging app

We are excited to begin rolling out the new version of Messenger on iOS. To make the Messenger iOS app faster, smaller, and simpler, we rebuilt the architecture and rewrote the entire codebase, whi…

Mohsen Agsen
14 min readintermediate
--
View Original

Overview

Project LightSpeed is an initiative aimed at rewriting the Messenger codebase to create a faster, smaller, and simpler messaging app. The new iOS version of Messenger is reported to be twice as fast to start and one-fourth the size of its predecessor, achieved by reducing the core code by 84% and leveraging native OS features and SQLite.

What You'll Learn

1

How to leverage native OS features to optimize mobile app performance

2

Why reducing code complexity is essential for app scalability

3

How to implement a universal database system using SQLite

4

When to push processing tasks to the server for better performance

Key Questions Answered

How did Messenger reduce its codebase from 1.7 million lines to 360,000?
Messenger achieved an 84% reduction in its codebase by rewriting the architecture and utilizing native OS features, dynamic templates, and a universal SQLite database. This allowed for a simpler, more efficient app while retaining essential features.
What are the main principles behind the new Messenger architecture?
The new Messenger architecture is based on four principles: using the OS for core functionalities, reusing UI components, leveraging SQLite as a universal database, and pushing processing tasks to the server. This approach minimizes code complexity and enhances performance.
What improvements were made to Messenger's startup time and app size?
The new Messenger app is reported to be twice as fast to start and one-fourth the size of the previous version, significantly enhancing user experience, especially on older devices.
How does the new Messenger handle data management and synchronization?
The new Messenger uses a single integrated schema in SQLite to manage data across features, which simplifies data access and synchronization. This approach reduces the complexity of client-server interactions and enhances app performance.

Key Statistics & Figures

Codebase reduction
84%
Reduced from more than 1.7 million lines to 360,000 lines.
Startup speed improvement
2x faster
Compared to the previous iOS version.
App size reduction
1/4 the size
The new Messenger app is significantly smaller than its predecessor.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Key Actionable Insights

1
Optimize your mobile app by leveraging native OS features to reduce complexity and improve performance.
Using the OS for tasks like rendering and threading can lead to significant efficiency gains, as demonstrated by Messenger's approach.
2
Implement a universal database system to streamline data management across app features.
By using SQLite as a central data management system, Messenger minimized the complexity of data interactions, which can be beneficial for any app with multiple features.
3
Establish strict code size budgets for features to prevent future code bloat.
Messenger's approach to holding engineers accountable for code size helps maintain a lean codebase, which is crucial for long-term app sustainability.

Common Pitfalls

1
Failing to optimize for code size can lead to performance issues and user dissatisfaction.
As seen with the previous version of Messenger, a large codebase can slow down app startup times and complicate user navigation.