Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Strategies of Facebook LightSpeed project

Strategies of Facebook LightSpeed project

A brief summary of the strategies of Facebook LightSpeed project

Elvis Lin

March 12, 2020
Tweet

More Decks by Elvis Lin

Other Decks in Programming

Transcript

  1. The motivation • Messenger first became a standalone app in

    2011 • The app that looked simple on the surface was far more complex behind the scenes • At its peak, the app’s binary size was greater than 130 MB • To make Messenger’s iOS app faster, smaller, and simpler
  2. The gains • Reduce 84% LoC (from 1.7M lines to

    360,000 lines) • The binary size becomes one-fourth of its original size (130 MB) • Twice as fast to launch
  3. Unified Architecture • Use the OS • Reuse the UI

    • Leverage the SQLite database • Use the Server (Push other logics to the server)
  4. Use the OS • If the OS did something well,

    used it (ex: the JSON processing library) • If the OS didn’t do something, found or wrote the smallest possible library code to address the specific need • For any cross-platform logic, used an operating extension built in native C code (ex: the Facebook-specific networking)
  5. Reuse the UI • Constrained the design to force the

    reuse of the same structure for different views • Instead of having the app store multiple screen designs, the database now holds instructions for how to display different building blocks depending on the various sub- features being loaded
  6. Use SQLite (2/2) • Simply using SQLite and letting it

    handle concurrency, caching, and transactions • All the caching, filtering, transactions, and queries are all done in SQLite. The UI merely reflects the tables in the database • built a platform (MSYS) to orchestrate all access to the database • MSYS is a cross-platform library built in C with 100 percent line code/test coverage
  7. Use the Server • How the server communicate with the

    client, https:// www.facebook.com/Engineering/videos/ 3509976602377949/ • A universal flexible sync system that allows the server to define and implement business and sync logic and ensures that all interactions between the client and the server are uniform • Built a server broker to support all these scenarios while the actual server back-end infrastructure supports the features
  8. Summary • More tests (tests are easily written) • Business

    Logic == Data Logic • Reduce + Reuse + Recycle • Global Metrics > Local Metrics (why uses a unified architecture) • Preventing future code growth (hugely)
  9. Reference • Project LightSpeed: Rewriting the Messenger codebase for a

    faster, smaller, and simpler messaging app
 https://engineering.fb.com/data-infrastructure/messenger/ • F8 2019: Facebook: Lighter, Faster, Simpler Messenger
 https://youtu.be/ulVLD2yzCrc • Discussion of LightSpeed on Hacker News
 https://news.ycombinator.com/item?id=22466462