Facebook 如何提高 iOS App 的 Newsfeed 的性能 50%

(原链接可能被墙了,打印成 pdf 放到这里 https://nfil.es/w/OWKCXl/) 这是今年 @Scale 上,Facebook 的这个 talk 的文字版。 Core Data 是瓶颈。 Core Data is at heart an object-relational mapper (ORM). It provides features like full normalization and synchronous consistency across multiple isolated contexts. But since the Facebook app is essentially a cache for data that lives on the server, a completely normalized representation of data wasn't needed. All of those fetch-or-creates while parsing JSON objects were resource-intensive and unnecessary. We developed our own bare-bones form of model objects guided by three principles:
  • Immutability. In this new data layer, models are completely immutable after creation.
  • Denormalized Storage. To serialize these models to disk, we chose to use NSCoding.
  • Asynchronous, Opt-In Consistency. By default, there are no consistency guarantees.