'Project LightSpeed': Messenger On iOS Is One-Fourth The Size But Twice Faster

WireGuard - Linux

Facebook Messenger has been one of the most complex and sophisticated messaging app. But things are changing.

The messaging app has been designed to be more streamlined, by eliminating the Discover tab and hiding Chatbot. On iOS, Facebook has gone a step further.

And by using what it calls 'Project LightSpeed', Facebook shrunk the app to literally a quarter of the size it used to be.

While some of the features have been removed, with Facebook alluded that they may make a comeback. But still, a forth of the size is quite extreme and indeed making it more manageable.

According to Facebook on its blog post:

"People turn to messaging apps throughout the day to stay in touch with the people they care about so it’s important the app loads quickly and is simple to use. On the heels of Messenger 4, we started a journey to simplify and redesign Messenger, internally called Project LightSpeed, and now we’ve rebuilt the iOS app from the ground up."
Facebook Messenger reuse UI

Detailing about the process, Facebook said that:

"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, which is an incredibly rare undertaking and involved engineers from across the company."

"Compared with the previous iOS version, this new Messenger is twice as fast to start and is one-fourth the size. We reduced core Messenger code by 84 percent, from more than 1.7M lines to 360,000."

The first thing Facebook's engineers did, was to minimize code complexity and eliminate redundancies.

So instead of having each feature with its own optimization, Facebook chooses to unify the architecture altogether.

Mobile operating systems continue to evolve, and Facebook acknowledges that existing operating systems are already offering much more than what it needs.

So here, rather than reinventing the wheel, the engineers used the UI framework available on the device’s native OS to support a wider variety of application feature needs. This reduced not only size, by avoiding the need to cache/load large custom-built frameworks, but also complexity.

To reduce redundancies, Facebook looked at the contact list screens which had 40 different designs. The engineers constrained the design to force the reuse of the same structure for different views.

With the updated Messenger, the contact list is a single dynamic template. This literally cuts the size further and also the speed.

Facebook Messenger people database

And for its database, Facebook Messenger uses SQLite, a database management system popular on most mobile apps. As features grew, Messenger ended up with new features built on top of its own cache. As a result, transferring the logic between the database and the UI slowed down the app.

The engineers decided to simply use SQLite, but let it handle everything from concurrency, caching, and transactions. So for example, instead of supporting one system to update which friends are active now, another to update changes in profile pictures in your contact list, and another to retrieve the messages you receive, all requests for data from the database are self-contained.

With all the caching, filtering, transactions, and queries are done in SQLite, Messenger's UI merely changes the tables in the database.

And for everything else that doesn't fit into the above, Facebook pushes it to its servers.

"Project LightSpeed ultimately required more than 100 engineers to complete and deliver the final product," Facebook said.

This version of Messenger also paves the way for Facebook to fulfill its mission in unifying its messaging apps in the future.

Published: 
04/03/2020