From Mononoke to the Rust Foundation

Facebook has moved from an early adopter of Rust to an official backer of the language, joining the Rust Foundation as a Platinum member alongside AWS, Microsoft, Google, and Mozilla. The company now counts hundreds of developers writing millions of lines of Rust across its codebase. That growth didn't happen overnight; it traces back to a source control bottleneck in 2016.

First Steps in Source Control

Facebook's oldest Rust code dates to a rewrite of its Mercurial source control back end. The project, called Mononoke, aimed to boost commit rates by orders of magnitude to accommodate thousands of developers and automated processes working in the company's monorepo. Although C++ was the default choice given Facebook's back-end stack, the Source Control team opted for Rust, prioritizing reliability over familiarity—corruption or downtime in source control can halt services across the company.

Mononoke was a natural test bed for Rust because it sat largely isolated from other Facebook systems. As long as it could speak Mercurial to clients and Thrift to storage systems, the choice of language didn't ripple outward. The team was also self-sufficient in building its own Rust tooling and infrastructure. That bet paid off: Mononoke has been the production back end for the monorepo since 2019.

The Adoption Curve

Mononoke proved Rust was viable at Facebook. Over the next two years, adoption spread to projects that could work in relative isolation—developer tools and small services that only needed a few wrappers around C++ client libraries. Engineers coming from Python and JavaScript backgrounds were drawn to Rust's combination of high performance and compile-time error detection. As success stories of two to four orders of magnitude performance improvements circulated internally, interest expanded to back-end service code and even mobile apps.

Growing Pains and Dedicated Support

From 2017 to 2019, the Source Control team doubled as Facebook's unofficial Rust support group. But by 2019, the number of Rust developers had grown past 100, and part-time assistance wasn't enough. A significant driver of that growth was the Diem blockchain project (formerly Libra), whose open source codebase is 94 percent Rust and which also spawned the Move programming language, developed in Rust.

Facebook created a small Rust developer experience team to handle tooling and integration challenges—for example, building the means to use the language's open source package registry ecosystem in production non-Cargo builds. The team became the central contact point for unblocking use cases, prioritizing developer experience issues, improving core libraries, and shepherding the codebase past the million-line mark.

A Longer-Term Mandate

At the end of 2020, Facebook upped its commitment by launching a Rust team within its Programming Languages organization, the same group responsible for C++ standards work and toolchains. This team has a broader scope than immediate developer experience concerns, taking on the health and growth of Rust as a language and community. Its near-term priorities fall into four areas:

  • Supporting internal users from a language and toolchain perspective, including rollouts, cross-cutting migrations, code review and audit, best practices, and a point of contact for questions.
  • Contributing to the wider Rust community by reviewing the standard library and compiler and providing resources toward community priorities.
  • Ensuring safe, easy Rust-C++ interoperability. Facebook's services sit atop a vast C++ back end, so Rust developers need to reach those libraries without losing Rust's safety benefits. And for Rust components to integrate with larger C++ binaries, async code needs to interoperate cleanly on Facebook's heavily threaded servers—a challenge the company has already tackled on the C++ side through its early adoption of C++20 coroutines.
  • Engaging with the Rust Foundation as a Platinum member to help drive the language's advancement and adoption.

The team is small for now but expected to grow as support needs scale. Rust's trajectory at Facebook continues through 2021, with plans spanning internal work, open source contributions, and community efforts.