A quick historical past of Rust at Fb

Facebook hugs Rust, one of the most loved and fastest growing programming languages ​​available today. Besides bringing new talent Facebook announced to its Rust team that it is officially joining the nonprofit Rust Foundation. In addition to colleagues like Mozilla (the makers of Rust), AWS, Microsoft and Google, Facebook will work to maintain and expand the language’s open source ecosystem.

For developers, Rust offers the power of older languages ​​like C ++ with a stronger focus on code security. Today, hundreds of developers on Facebook are writing millions of lines of Rust code. And while it is clear that Facebook is increasingly investing in the future of language, it’s important to understand how we’ve grown to that point.

2016–2017: Early use in source code management

Our oldest Rust codebase dates back to 2016, when the rate of change of source code in Facebook’s Monorepo began to affect the maximum rate of commit that Mercurial’s source control management tool could keep up with. In response, Facebook’s Source Control team started a rewrite project called Mononoke with the aim of adding a few extra orders of magnitude to Mercurial’s commit rate to serve Facebook’s thousands of developers and automated processes.

Developing Mononoke in C ++ was the obvious choice at first. At the time, Facebook’s back-end code base was very C ++ heavy, which means that Mononoke would have been implemented in C ++ by default. However, the source control team had to consider the reliability requirements of the source control backend. When corruption or downtime can potentially bring services to a standstill, reliability is a top priority. Because of this, the team chose Rust instead of C ++.

Jeremy Fitzhardinge, a software developer in production trust at Facebook, describes this experience in one Lecture at RustConf 2019.

Mononoke served as a great test bed as it was, of course, quite isolated from other Facebook systems. As long as Mononoke can use the Mercurial protocol to talk to client services and the Thrift protocol to talk to some storage systems, choosing Rust will not affect the work of the Source Control team.

The Source Control team was ready and able to support each other in all grate-specific tools and infrastructures. This worked out fine, and Mononoke has been the production backend for our Monorepo since 2019, which has successfully scaled up over the years.

2017–2019: The adoption curve

With Mononoke as evidence that it was profitable and lived up to its needs over time, other projects have also considered and adopted Rust. Initially, these were usually developer tooling projects that didn’t need to be integrated into the broader service infrastructure, or small services / daemons that could do their job with just a few handwritten wrappers around a few C ++ client libraries.

Many of the engineers on Facebook who took over Rust were from Python and Javascript. They appreciated Rust’s combination of high performance and compile-time error detection. With the company floating around success stories like performance improvements on the order of two to four orders of magnitude, interest grew in using Rust for back-end service code and exploring its use in mobile apps as well.

2019-2020: Some dedicated support for Rust

From 2017 to 2019, the Source Control team acted as the unofficial Rust support team within Facebook. By 2019, the number of Rust developers on Facebook had grown exponentially to over 100.

As a significant example of this growth, Rust is the leading language in the development of the Diem (formerly Libra) blockchain monitored by the independent Diem Association. Facebook is a member of the Diem Association through its Novi digital wallet. The Diem blockchain is mostly written in Rust and covers 94 percent of the open source Code base. In addition, MoveWith Rust, a new, secure programming language has been developed for the blockchain.

With this growing need, the part-time support from the Source Control team was not enough to support the number of teams that can benefit.

We have assembled a small Rust development team that will focus their attention on tooling and integration challenges like building the mechanism for using the language’s open source package registration ecosystem in production non-cargo builds. The team formed a single point of contact for Rust developers across the enterprise to share use cases, prioritize short-term developer experience concerns, improve core libraries, and generally set up the young Rust code base for success when it crosses the million dollar mark.

Next (2021 and beyond)

At the end of 2020, we reinforced our commitment again by setting up a Rust team in our organization for programming languages, which is also responsible for the C ++ standard work and toolchains for Facebook.

This team has a longer-term focus that goes beyond the immediate priorities of the developer experience in the context of our code base. In particular, all contributions to the growth and maintenance of Rust as a healthy and productive language and community are now in scope.

In the short term, this new team will focus on four areas:

  • Support of internal users from the point of view of language and the toolchain: This includes toolchain rollouts, overarching migrations, code reviews / reviews, best practices and contacting you for language and toolchain issues.
  • Positive contribution in the community outside of Facebook: The team conducts code reviews of the standard library and compiler, and allocates developer resources to prioritize the Rust community.
  • Easy and secure interoperability of Rust with C ++: We have a large amount of C ++ code that is required to communicate with the back-end systems on which the services are based. We need developers who can safely and easily use these libraries without sacrificing the benefits of Rust. Conversely, we need intelligent run-time interoperability in asynchronous code if Rust components are to be integrated into our larger C ++ binaries. Facebook’s servers are widely distributed and heavily used. Rust tasks must function well in a C ++ thread pool and safely share synchronization primitives and I / O resources. We have already done a lot of work in the C ++ area to improve asynchronicity, as we supported the C ++ 20 coroutines and quickly adopted them. Bringing Rust into the game will be an extension of this, building on the excellent work already being done in Rust’s asynchronous library stack.
  • Active support and collaboration with the Rust Foundation: Facebook has been committed to the Rust community since 2016 and is expanding its development with Rust. We’re taking that commitment even further by joining the Rust Foundation as platinum memberWe hope that we can continue to help drive progress and adoption proactively and effectively.

Rust’s journey within Facebook is far from over. This team is small, but it will grow over time as the need for support increases. We’re excited and optimistic about Rust’s development on Facebook and across the industry. Our plans for working within Facebook, open source posting, and more community-oriented work will evolve over the course of 2021.

Comments are closed.