BlogsMetaFacebook Engineering Blog

Facebook Engineering Blog

Facebook Engineering Blog

145
posts
2008–2026

Meta's engineering blog has evolved to serve as a platform for sharing technical details, architecture discussions, and code samples related to the systems that power Facebook. The blog aims to provide insights into how the site scales smoothly and ensures a high-quality user experience, covering a wide range of engineering topics. This includes collaborations with external organizations like Wikipedia to improve infrastructure software, such as their transition to HHVM which resulted in significant performance improvements. Recent advancements include the development and deployment of Jump-Start for the HipHop Virtual Machine (HHVM), which significantly reduces warm-up overhead and improves steady-state performance for Facebook's apps and websites.

2026

The Death of Traditional Testing: Agentic Development Broke a 50-Year-Old Field, JiTTesting Can Revive It

2/11/2026

This post introduces Just-in-Time Tests (JiTTests) as a novel approach to software testing, leveraging LLMs to automatically generate tests on-the-fly for specific code changes. It highlights how JiTTests address the limitations of traditional testing in the context of agentic development by eliminating maintenance overhead, reducing false positives, and focusing on catching critical bugs just before production.

CSS at Scale With StyleX

1/12/2026

This post introduces StyleX, a new styling system for CSS at scale, which combines CSS-in-JS ergonomics with static CSS performance. It enables atomic styling of components, deduplicates definitions to reduce bundle size, and provides a simple API for developers. StyleX is now the standard styling system across Meta's major products and has been adopted by companies like Figma and Snowflake.

2025

StyleX: A Styling Library for CSS at Scale

11/11/2025

This post introduces StyleX, Meta's new styling system for large-scale applications. StyleX addresses historical challenges with CSS at Meta, such as collisions, dependency management, and specificity wars, by compiling styles at build time into collision-free atomic CSS. It offers an expressive and type-safe approach to style authoring, combining CSS-in-JS ergonomics with static CSS performance. The post details StyleX's compiler, its core APIs (stylex.create, stylex.props), and its principles of scalability, expressiveness (shareable values, styling at a distance, preserving CSS features), and predictability, making it the default styling system across Meta products.

Branching in a Sapling Monorepo

10/16/2025

This post introduces Sapling, Meta's open-source source control system designed for its large monorepo. It details the development and open-sourcing of a novel monorepo branching solution, specifically 'directory branching,' which addresses the scalability and developer experience challenges of traditional full-repo branching in a monorepo environment. It also discusses integration with build systems like Buck2 and potential future work on Git repository integration.

Enabling Kotlin incremental compilation on Buck2

8/26/2025

This post details the integration of Kotlin's incremental compiler into Meta's Buck2 build system. It explains the technical challenges and solutions involved, including using the Kotlin Build Tools API, managing build outputs, making the compiler cache relocatable, configuring change tracking for modules and dependencies, and adapting compiler plugins and annotation processors for incremental compilation. This effort significantly speeds up compilation times for critical modules, improving developer productivity.

An inside look at Meta’s transition from C to Rust on mobile

7/1/2025

This post details Meta's initiative to transition a core messaging library from C to Rust. It highlights the challenges and approach to modernizing legacy code at scale, emphasizing the optimization for 'developer happiness' as a key driver for adopting Rust. The effort impacts multiple Meta products including Messenger, Facebook, and Instagram, as well as AR/VR platforms.

Meta’s Full-stack HHVM optimizations for GenAI

5/20/2025

This post details full-stack HHVM optimizations for GenAI workloads. Key contributions include splitting GenAI inference traffic into a dedicated WWW tenant for specialized runtime and warm-up configurations, leading to a 30% latency improvement. Specific optimizations include increasing the request runtime limit, adjusting thread-pool sizing for longer-running requests, leveraging HHVM's Jump-Start for faster JIT compilation, implementing request warm-up to pre-cache configuration and service discovery info, and using request shadowing to maintain JIT cache coverage for feature rollouts.

Open-sourcing Pyrefly: A faster Python type checker written in Rust

5/15/2025

This post announces the open-sourcing of Pyrefly, a new Python type checker written in Rust. It details the evolution of this tool from an internal project at Instagram to a community-available resource. The post highlights Pyrefly's capabilities as an incremental type checker that scales to monorepos and its integration with IDEs and CLI usage. It also mentions the underlying technology choices, such as Rust, and its adherence to Python type hinting standards (PEP 484).

Introducing Pyrefly: A new type checker and IDE experience for Python

5/15/2025

Introduced Pyrefly, a new open-source Python type checker and IDE extension written in Rust. Pyrefly aims to provide high performance (1.8 million lines of code per second), an IDE-first design, and type inference capabilities. It builds upon the experience gained from developing the Pyre type checker for Instagram's codebase, addressing limitations in Pyre's extensibility and IDE responsiveness. The post details the principles behind Pyrefly's design and encourages community contribution.

How Meta is translating its Java codebase to Kotlin

2/25/2025

This post details Meta's ongoing effort to translate its substantial Android codebase from Java to Kotlin. It highlights the scale of the migration (tens of millions of lines of code), the development of open-sourced tools for manipulating Kotlin Abstract Syntax Trees (ASTs), and the challenges encountered, such as avoiding nullability issues and generating idiomatic code for internal frameworks. The post also references a podcast episode for deeper technical discussion.

Measuring productivity impact with Diff Authoring Time

1/16/2025

This post introduces Diff Authoring Time (DAT) as a metric for measuring developer productivity, building upon previous work. It highlights two specific use cases for DAT, including its application with a type-safe mocking framework in Hack, and promotes a podcast episode that delves deeper into these experiments and the use of metrics for productivity analysis.

2024

Indexing code at scale with Glean

12/19/2024

This post introduces Glean, Meta's open-source system for code indexing, which significantly enhances developer tooling. It explains the importance of code indexing for tools like IDEs, code search, and documentation generation, especially in large codebases. The post details Glean's design rationale, emphasizing its generality, flexible query language (Angle), and ability to store arbitrary data. It also highlights Glean's innovative incremental indexing approach for efficient processing of changes. The post further elaborates on how Glean is used at Meta for code navigation, providing instant availability, wider integration, full repository visibility, and cross-language navigation, and also for speeding up IDE performance.

Translating Java to Kotlin at Scale

12/18/2024

This post details Meta's multi-year effort to migrate its Android codebase from Java to Kotlin. It describes the development of an automated translation tool called the Kotlinator, which comprises six phases: deep build, preprocessing, headless J2K, postprocessing, linters, and build error-based fixes. The post highlights the challenges of automating this process at scale, the custom tooling developed to handle framework-specific changes and nullability, and the collaboration with JetBrains to improve the J2K tool for future compatibility with the K2 compiler.

Typed Python in 2024: Well adopted, yet usability challenges persist

12/9/2024

This post details the findings of a collaborative survey conducted by Meta, JetBrains, and Microsoft on the state of Python typing. It highlights the high adoption rate of type hints (88%), the key drivers for this adoption (IDE tooling, documentation, bug catching), and persistent usability challenges. The post also identifies common issues with type system documentation, performance of type checkers, inconsistencies across tools, and the need for better support for dynamic features. Recommendations are provided for Python language maintainers and tooling authors, emphasizing standardization, consistency, performance, and improved documentation discoverability. This contributes to the ongoing evolution of Meta's developer tooling and language support by providing data-driven insights into the Python ecosystem.

The key to a happy Rust/C++ relationship

6/25/2024

This post discusses the integration challenges and solutions for using Rust alongside Meta's existing C++ codebase. It highlights the release of 'cxx' as a key enabler for safe C++/Rust interop and mentions the facilitation of async Rust, contributing to the evolution of Meta's server-side language ecosystem.

How DotSlash makes executable deployment simpler

2/26/2024

Introduced DotSlash, an open-source tool that simplifies executable deployment by combining a Rust program with a JSON manifest to transparently fetch and execute binaries, reducing the need to commit large, platform-specific executables to repositories.

Meta loves Python

2/12/2024

This post highlights Meta's significant contributions to the Python language, specifically focusing on new features developed for Python 3.12. These contributions include custom JITs like Cinder, Immortal Objects, type system improvements, and faster comprehensions. The post emphasizes Meta's collaborative approach with the Python community and showcases how these advancements are integrated into Meta's internal development practices, such as with Cinder for machine learning.

2023

Writing and linting Python at scale

11/21/2023

This post discusses Meta's ongoing efforts to improve the Python developer experience at scale, highlighting the work of the Python Foundation Team and the open-sourced Fixit 2 linter framework. It also touches upon the role of production engineers at Meta.

5 Things you didn’t know about Buck2

10/23/2023

This post introduces Buck2, the successor to Meta's open-source build system Buck. It highlights Buck2's development in Rust for performance and memory control, its use of Starlark for language-specific rules, its ability to avoid downloading intermediate build outputs through remote execution, its extensive internal file path type system for enhanced type safety, its language-agnostic core with Starlark-defined language specifics, and the introduction of BXL for advanced graph interaction and extension. This post significantly details the evolution and advanced capabilities of Meta's build system, building upon the general theme of developer tools and efficient code generation.

Meta contributes new features to Python 3.12

10/5/2023

This post details Meta's significant contributions to the Python 3.12 release, including the implementation of 'Immortal Objects' (PEP 683) to reduce memory usage and enable better parallelism, type system improvements with the '@typing.override' decorator (PEP 698) for safer refactoring, and various performance optimizations such as faster comprehensions (PEP 709), eager asyncio tasks, faster super() calls, and optimizations for hasattr and unittest.mock.Mock. Meta also contributed new benchmarks to the Python Performance Benchmark suite and added core runtime hooks for Cinder (their JIT compiler and Static Python) to enable independent extension modules. This work stems from Meta's extensive use of Python and their commitment to open-source contributions to improve the language for all users.

Introducing Immortal Objects for Python

8/15/2023

Introduced Immortal Objects (PEP-683) to Python, allowing objects to bypass reference count and garbage collection checks for true immutability. This reduces private memory usage and increases shared memory by minimizing copy-on-write operations in multi-process Python applications, as demonstrated with Instagram's frontend servers. The implementation involved addressing backward compatibility, platform compatibility, and performance regressions, resulting in a ~2% performance regression. This contribution is a foundational step towards a multi-core Python runtime, supporting proposals like Per-Interpreter GIL (PEP-684) and Optional GIL (PEP-703).

Fixit 2: Meta’s next-generation auto-fixing linter

8/7/2023

Introduces Fixit 2, a next-generation auto-fixing linter for Python, built on LibCST. Fixit 2 supports custom, in-repo lint rules and hierarchical configuration, addressing limitations of previous tools like Flake8. It enables developers to efficiently build lint rules and perform auto-fixes, improving code quality and developer productivity. The post details the architecture, rule writing, auto-fix suggestion mechanism, and usage examples.

Meta developer tools: Working at scale

6/27/2023

This post introduces and details Meta's developer tools designed for extreme scale: Sapling (version control with a server, client, and virtual file system using Rust), Buck2 (a large-scale build system supporting remote caching, execution, and multi-language dependencies), and static analysis/testing tools like Infer, RacerD, and Jest. It highlights how these tools address challenges with millions of files and complex codebases, emphasizing their open-source nature and integration with systems like EdenFS and Watchman.

Build faster with Buck2: Our open source build system

4/6/2023

This post introduces Buck2, Meta's new open-source, large-scale build system written in Rust. It details the architectural changes from Buck1, including the separation of core and language-specific rules, a single incremental dependency graph, and integration with remote execution and virtual file systems. It highlights performance improvements, with builds completing twice as fast as Buck1, and discusses the user and rule author perspectives, including new features like dynamic output for OCaml dependencies and transitive sets for C++ link dependencies.

The evolution of Facebook’s iOS app architecture

2/6/2023

This post details the evolution of the Facebook iOS app architecture over 10 years, highlighting key technical decisions and their impact. It covers the shift from Core Data and MVC to a custom declarative UI framework (ComponentKit) for improved performance and maintainability, and the strategic adoption of dynamically loaded libraries (dylibs) to manage app size and startup performance. The post also discusses the challenges and solutions related to dylib integration, including runtime failures and linker errors, and the subsequent reliance on the Buck build system for code generation and dependency management.

2022

Retrofitting null-safety onto Java at Meta

11/22/2022

Introduced Nullsafe, a new static analysis tool for Java that detects NullPointerException (NPE) errors. Nullsafe was integrated into the core developer workflow and used for a large-scale code transformation across millions of lines of Java code. This resulted in a 27% reduction in production NPE crashes for Instagram and improved developer productivity. The post details the technical challenges of null-safety in Java, the design of Nullsafe using AST and CFG, and its two-phase analysis (type inference and type checking).

Sapling: Source control that’s user-friendly and scalable

11/15/2022

This post introduces Sapling, a new Git-compatible source control client developed by Meta, emphasizing usability and scalability for massive repositories. It highlights key features like smartlog for repository visualization, simplified mistake recovery, and first-class support for commit stacks. The post also announces the open-sourcing of the Sapling client and previews future plans for open-sourcing the server and virtual file system components, along with the development of ReviewStack for stack-oriented code reviews.

From zero to 10 million lines of Kotlin

10/24/2022

This post details Meta's large-scale migration of its Android codebase from Java to Kotlin, involving over 10 million lines of code. It outlines the technical motivations for adopting Kotlin, including its advantages in nullability, functional programming, and code conciseness. The post also discusses the challenges encountered, such as build time increases and interoperability issues, and describes the multi-step pipeline developed to automate the conversion process, including custom tooling like Ktfmt and postprocessing refactors. Examples of specific conversion challenges, like JUnit testing rules and the replacement of Java utility methods with Kotlin's standard library equivalents, are provided.

Launching a new Chromium-based WebView for Android

9/30/2022

This post details the development and launch of a custom Chromium-based WebView for the Facebook app on Android. This initiative aims to improve security by allowing timely application of Chromium security patches, enhance stability by preventing app crashes during System WebView updates, and boost performance through optimized rendering capabilities. It also highlights Meta's ongoing commitment to open source by contributing to Chromium and adopting industry best practices.

MemLab: An open source framework for finding JavaScript memory leaks

9/12/2022

This post introduces MemLab, an open-source JavaScript memory testing framework developed by Meta. MemLab automates the detection and root-causing of memory leaks in web applications, addressing a critical challenge in maintaining performance and user experience for single-page applications. It works by automating browser interactions, diffing JavaScript heap snapshots, generating retainer traces, and clustering them for analysis. The framework also provides a graph-view API for heap analysis and memory assertions for Node.js programs and Jest tests, enhancing the developer's ability to optimize memory usage and prevent out-of-memory crashes.

Programming languages endorsed for server-side use at Meta

7/27/2022

This post details Meta's internal guidance on supported server-side programming languages, with Rust being the latest addition. It explains the criteria for a 'supported' language, the rationale behind language decisions (performance, security, operational risk, expertise, developer experience), and the specific recommendations for Hack, C++, Rust, and Python based on use cases (business logic, performance-sensitive back-ends, CLI tools, data science, ML, and Instagram). It also mentions other supported languages like Java, Erlang, Haskell, and Go for specific use cases.

Building text animations for Instagram Stories

7/18/2022

This post details the development of new text styles and animations for Instagram Stories and Reels, highlighting the engineering challenges and solutions. Key contributions include: developing a custom solution for font delivery on Android using Everstore and Haystack to avoid increasing APK size; implementing dynamic text animations by collaborating closely with designers to overcome technical limitations, such as the 'Directional' text style; and solving complex text rendering issues on Android, including handling ligatures, emojis, RTL text, and custom spans for emphasis and selective coloring, by leveraging native APIs like TextPaint and BreakIterator.

How the Cinder JIT’s function inliner helps us optimize Instagram

5/2/2022

This post details the implementation and benefits of the function inliner pass within Cinder's Just-In-Time (JIT) compiler. It explains how the JIT transforms Python bytecode into native code through various intermediate representations (HIR, SSA HIR, LIR) and how function inlining allows for greater type specialization, removal of function call overhead, and potential constant folding. The post illustrates the process with code examples of Python functions being compiled and optimized, highlighting the reduction in overhead and the ability to specialize operations like addition.

VESPA: Static profiling for binary optimization

3/15/2022

Introduced VESPA (Vintage ESP Amended), a novel approach to static profiling for binary optimization. VESPA uses machine learning to infer branch instruction probabilities and derive code frequencies without requiring dynamic profiling, enabling binary optimizers like BOLT to improve performance for applications where dynamic profiling is prohibitive, such as end-user mobile applications. This research demonstrates a 6% speedup on top of highly optimized binaries built with Clang -O3.

An open source compositional deadlock detector for Android Java

3/8/2022

This post introduces a new open-source compositional deadlock detector for Android Java, integrated into Meta's CI system. It leverages abstract interpretation and a novel heuristic to analyze hundreds of millions of lines of code, leading to over 200 deadlock fixes in the Android app family. This advancement significantly enhances Meta's commitment to robust development tools and proactive bug detection within its engineering practices.

2021

A brief history of Rust at Facebook

4/29/2021

This post details Meta's adoption and integration of the Rust programming language, tracing its journey from early use in source control (Mononoke) in 2016-2017, through wider adoption in developer tooling and small services (2017-2019), to dedicated support teams and significant contributions to projects like the Diem blockchain (2019-2020). It highlights the establishment of a Rust team in 2020 to focus on internal tooling, community contributions, C++/Rust interoperability, and engagement with the Rust Foundation.

Reverse debugging at scale

4/27/2021

This post introduces a novel reverse debugging technique for large-scale production environments. It details the use of Intel Processor Trace (Intel PT) and eBPF for continuous, low-overhead tracing of CPU activity, enabling engineers to inspect the history of a failing process without rerunning it. The contribution includes the development of a system for quick storage of trace data, decoding and symbolication using LLDB, reconstruction of function call history, and support for latency analysis, ultimately aiming to drastically reduce the time spent debugging production issues.

Boosting the performance of virtual machines with Jump-Start

3/3/2021

Introduced Jump-Start, a novel technique to reduce virtual machine warm-up overhead by leveraging phased rollouts. Profile data collected from a small fraction of servers (C2) is shared with the majority (C3), allowing them to skip initial compilation and profiling. This resulted in a 54.9% reduction in HHVM overhead during warm-up and a 5.4% improvement in steady-state performance for Facebook's apps and websites. This technique also enables more thorough profiling and new optimizations.

2020

Infer powering Microsoft’s Infer#, a new static analyzer for C#

12/14/2020

This post details the extension of Meta's Infer static analysis platform to support C# through Infer#. This involves creating a new language front end for C# that compiles .NET bytecode to Infer's intermediate language (SIL), and introducing a language-independent JSON layer for SIL, paving the way for future language support. It highlights Infer#'s ability to find deep inter-procedural bugs in C# code, similar to what Infer does for Java and C++.

Retrie: Haskell refactoring made easy

7/6/2020

Introduced Retrie, an open-source Haskell refactoring tool that allows developers to express code rewrites as equations in Haskell syntax, offering a middle ground between string manipulation and AST manipulation tools. Retrie supports rewriting expressions, types, and patterns, scripting rewrites with side conditions, and preserves local scoping and whitespace. It was used to safely migrate Sigma's rules to new APIs and libraries.

Rebuilding our tech stack for the new Facebook.com

5/8/2020

This post details the rearchitecture of Facebook.com using React and Relay. Key technical contributions include: a complete rewrite of the frontend to achieve an app-like feel and performance; a new CSS strategy using atomic CSS generated at build time, colocation of styles with components, CSS variables for theming (dark mode), and inlining SVGs for faster rendering; a JavaScript code-splitting strategy with three loading tiers (Tier 1 for initial paint, Tier 2 for full above-the-fold content, Tier 3 for post-display needs) to optimize incremental code download; and an improved data fetching and navigation architecture.

2019

Simon Marlow, Simon Peyton Jones, and Satnam Singh win Most Influential ICFP Paper Award

10/24/2019

This post highlights the significant impact of a 2009 paper on 'Runtime Support for Multicore Haskell' by Simon Marlow, Simon Peyton Jones, and Satnam Singh, which enabled Haskell to run efficiently on parallel hardware. It details how this work directly influenced Meta's adoption of Haskell for its abuse protection system, Sigma, leading to substantial performance improvements and increased traffic handling capacity. The post underscores the evolution of programming language capabilities and their direct application to large-scale, critical engineering challenges at Meta.

F8 2019 Day 1 keynote and session videos

5/1/2019

This post details several technical sessions from F8 2019, highlighting Meta's use of React, GraphQL, and Relay for building Facebook.com, including React Suspense. It also covers advancements in mobile development with React Native, ComponentKit, and Litho, and the NLP service Wit.ai. The use of Docusaurus for open-source websites, Python's role in Meta's infrastructure, and the development of a new Messenger app review chat support channel are discussed. Technical deep dives into building Messenger automated experiences, internationalization at scale with FBT, and the development of a mobile AI platform for edge ML are presented. Finally, the rebuilding of Messenger from the ground up for improved performance is outlined.

Faster input events with Facebook’s first browser API contribution

4/22/2019

This post details Meta's first contribution to a web browser API, the `isInputPending` API. It addresses the critical issue of 'queueing time' in web interactions, which is the delay between a user input event and the start of its processing. The API allows JavaScript to check if input events are pending, enabling developers to yield control to the browser more effectively, thus resolving the trade-off between fast page loading and quick event response. This initiative highlights Meta's active role in web standards and its commitment to improving the web platform.

Releasing Hooks for React 16.8

2/22/2019

Introduced React Hooks (useState, etc.) as a new pattern for writing React components, enabling state and lifecycle features within function components. Hooks are backward compatible and aim to simplify code reuse and organization by avoiding the drawbacks of render props and higher-order components.

Open-sourcing SPARTA to make abstract interpretation easy

2/20/2019

This post introduces SPARTA, a C++ library of software components for building high-performance static analyzers. SPARTA encapsulates complex implementation details of abstract interpretation, allowing engineers to focus on program properties, analysis granularity, and property representation. It provides data structures like finite lattices and power set domains, and algorithms like a generic fixpoint iterator. The library's use in ReDex for liveness analysis resulted in a 60% speedup and 90% memory reduction. SPARTA is language-independent and designed for industrial-scale use, with an invitation for community contributions.

2018

Finding and fixing software bugs automatically with SapFix and Sapienz

9/13/2018

This post introduces SapFix and Sapienz, AI-powered tools designed to automate the detection and fixing of software bugs. SapFix can automatically generate and propose fixes for bugs, and has been used at scale on the Facebook Android app. Sapienz assists in localizing bugs, and SapFix then uses various strategies (reverting, templated fixes, mutation-based fixes) to generate patches. These patches are autonomously validated against existing and Sapienz-generated tests before being presented to human reviewers for approval. This marks a significant step towards automated debugging and code improvement at scale.

XARs: An efficient system for self-contained executables

7/13/2018

This post introduces XARs (Executable Archives), a new system for distributing self-contained executables. XARs encapsulate code and data dependencies into single, highly compressed files, offering significant improvements in distribution speed, robustness, and efficiency compared to previous methods like PARs and PEX files. They leverage squashfs and FUSE for on-demand mounting and execution, minimizing overhead and enabling hermetic binaries that run consistently across diverse infrastructure. The post details the technical implementation, performance benefits, and provides usage examples for various platforms, while also highlighting its open-source release.

HotSwap: Bringing hot code reloading to Buck

2/28/2018

Introduced HotSwap, a feature for Buck that enables hot code reloading for Android development. HotSwap leverages Buck's Exopackage support and Java ClassLoaders to allow engineers to incrementally update code without restarting the entire application, drastically reducing the time to verify bug fixes and improving the overall edit-compile-run cycle. It achieves this by inserting a delegate ClassLoader that can be dropped and repopulated from disk when definitions change, leading to a 90% decrease in verification time for bug fixes in benchmarks.

2017

Rethinking Android app compilation with Buck

11/9/2017

This post introduces significant performance improvements to Buck's Java compilation process for Android engineers. Key contributions include: 1. Ignoring unused classes by detecting class usage during compilation, reducing rebuilds by 35%. 2. Implementing rule pipelining by generating stub JARs halfway through the Java compiler's run, reducing build times by 10% through increased parallelism. 3. Introducing source-only stub generation, which flattens the build graph by generating stub JARs directly from source without requiring full dependency compilation, leading to further parallelism and reduced build times.

React 16: A look inside an API-compatible rewrite of our frontend UI library

9/26/2017

This post details the internal rewrite of React to React Fiber (later React 16), focusing on the engineering process. Key contributions include the use of feature flags for parallel development, the extensive use and evolution of the Jest test suite to achieve feature parity, the development of `isfiberreadyyet.com` for progress tracking, and a phased dogfooding and rollout strategy across Facebook's web and mobile applications. The rewrite enabled asynchronous rendering and introduced error boundaries.

Announcing Yarn 1.0

9/7/2017

This post announces the 1.0 release of Yarn, a JavaScript package manager that Meta has adopted across many of its major codebases (Facebook app, Instagram, Oculus, WhatsApp). It highlights Yarn's impact on reducing install times, improving stability, and enabling large-scale dependency management. Key new features introduced in Yarn 1.0, such as Yarn Workspaces for monorepos, auto-merging of lockfiles, and selective version resolutions, are detailed. The post emphasizes the significant community involvement in Yarn's development and Meta's role in adopting and contributing to this critical developer tool, showcasing a broader trend of Meta leveraging and shaping open-source developer infrastructure.

Finding inter-procedural bugs at scale with Infer static analyzer

9/6/2017

This post details the development and application of the Infer static analyzer, highlighting its ability to find inter-procedural bugs in large codebases (Java and C) that other tools miss. It showcases Infer's effectiveness with examples from DuckDuckGo and OpenSSL, demonstrating its impact on improving code quality and reliability by identifying thousands of bugs in Meta's internal code.

AL: A new declarative language for detecting bugs with Infer

5/24/2017

This post introduces AL, a new declarative language designed to simplify the creation of custom bug detection checkers for Meta's static analysis tool, Infer. AL allows developers to define new checks with minimal static analysis expertise by reasoning about abstract syntax trees, making it easier to identify specific types of bugs, such as incorrect property declarations, without needing to modify Infer's core OCaml source code. This enhances the extensibility and practical application of Infer for mobile code analysis.

Relay Modern: Simpler, faster, more extensible

4/18/2017

This post introduces Relay Modern, a significant evolution of Meta's data-fetching framework for React applications. It emphasizes performance improvements for mobile devices through static queries and ahead-of-time optimization, a simplified API for mutations, and built-in garbage collection. Relay Modern also modularizes the framework into compiler, runtime, and integration layers, enhancing extensibility and reusability.

Building virtual reality experiences on the web with React VR

4/18/2017

This post introduces React VR, a new library that allows developers to build virtual reality experiences using standard web technologies and JavaScript. It extends the declarative programming style of React and React Native to 3D environments, enabling the creation of immersive VR content accessible on web browsers, mobile phones, and PCs. The library leverages WebGL and WebVR, and its architecture is built upon React Native principles, utilizing web workers for performance optimization. This initiative democratizes VR content creation by lowering the barrier to entry for web developers.

2016

Facebook Open Source 2016 year in review

12/19/2016

This post provides a comprehensive year-in-review for Facebook's Open Source program in 2016, highlighting the launch of 77 new projects and 60,000 commits. It showcases the continued growth and momentum of flagship projects like React and React Native, the successful launch of new tools such as Draft.js and create-react-app, and significant industry collaborations on projects like Yarn and Infer. The post also details contributions to core infrastructure like Linux and Chef, and the open-sourcing of AI research (fastText) and hardware (Surround360), underscoring Meta's commitment to open collaboration and community building.

Components for Android: A declarative framework for efficient UIs

10/26/2016

This post introduces Components for Android (C4A), a new declarative UI framework for Android development. Inspired by React and ComponentKit, C4A addresses the challenges of building performant and memory-efficient scrollable UIs, such as those found in Facebook's News Feed. It achieves this through a declarative API, asynchronous layout, flatter view hierarchies, incremental mount, and fine-grained recycling, leading to improved scroll performance and developer productivity.

Yarn: A new package manager for JavaScript

10/11/2016

Introduced Yarn, a new open-source JavaScript package manager developed in collaboration with Exponent, Google, and Tilde. Yarn addresses issues of consistency, security, and performance encountered with the npm client at scale. Key technical contributions include deterministic dependency resolution using lockfiles, a global cache for offline installs and faster fetching, parallelized installation steps (resolution, fetching, linking), and a mutex for concurrent CLI instances. Yarn aims to provide a faster, more reliable, and secure alternative to npm while remaining compatible with the npm registry.

Redesigning the HHVM JIT compiler for better performance

9/22/2016

This post details a major redesign of the HHVM JIT compiler, introducing profile-guided optimizations (PGO) to improve performance. The redesign involved transforming HHVM into a multi-gear system that uses a profiling gear to collect runtime execution data and an optimizing gear to recompile code into larger, more efficient regions. This approach overcomes the limitations of the previous tracelet-based compilation, enabling better optimization decisions and reducing overheads. The implementation was incremental, with initial improvements in 2014 and full support for arbitrary code regions by spring 2015, resulting in a 15% reduction in CPU usage.

Peter O’Hearn elected Fellow of the Royal Academy of Engineering

9/9/2016

This post highlights the election of engineer Peter O'Hearn as a Fellow of the UK Royal Academy of Engineering for his pioneering work on separation logic. This theory underpins Facebook's open-source static analysis tool, Infer, which catches over 1,000 bugs per month, saving engineers time and improving user experience. The post emphasizes Infer's ability to model program behavior and reason about independent code parts, scaling to large codebases and gaining adoption by other companies.

What’s new in Facebook open source

7/15/2016

This post details Meta's expanding commitment to open source, highlighting the release of 54 new projects in the first half of 2016. It showcases specific contributions like Draft.js for rich text editing, ReDex for Android app optimization, and a suite of iOS memory profiling tools. It also mentions open-sourcing AI research tools (Torch implementations, Torchnet), a security CTF platform, and the Reason interface for OCaml, underscoring a strategic effort to collaborate with and benefit from the broader developer community.

Improving CSS quality at Facebook and beyond

6/13/2016

This post details the migration from a homegrown, regex-based CSS linter to a more robust solution using PostCSS and Stylelint. It highlights the benefits of using an Abstract Syntax Tree (AST) for parsing CSS, enabling more sophisticated static analysis, custom rule creation (e.g., for performance-sensitive properties, SVG filters, variable usage, common typos, mobile flexbox compatibility, and internationalization-unfriendly text transformations), and the development of automatic replacement features. The post also emphasizes the importance of unit testing for linters and discusses future plans for gathering codebase statistics and adapting to CSS-in-JS approaches.

Automatically push commits to GitHub with FBShipIt

4/20/2016

This post introduces FBShipIt, an open-sourced tool developed internally to automate the process of pushing commits from Facebook's internal Mercurial repositories to GitHub. It addresses challenges like moving files, removing confidential information, and handling differences between Git and Mercurial, thereby reducing manual effort for engineers and enabling continuous integration for interdependent projects.

Facebook Chef cookbooks

4/16/2016

This post announces the open-sourcing of 14 internal Facebook Chef cookbooks, providing a standardized and hierarchical approach to server configuration management. It details the history of their involvement with Chef, the refactoring of core cookbooks for generic use, and provides a quick start guide and examples of how to leverage these cookbooks for managing system settings like sysctls, limits, log rotation, and fstab entries. The contribution aims to enable other organizations to adopt Facebook's model of Chef for easier and faster server setup.

Facebook open sources rich text editor framework Draft.js

2/26/2016

This post introduces Draft.js, a React-based rich text editor framework open-sourced by Meta. It details the challenges faced with traditional rich text editing (e.g., using <textarea> and <div> tags) and how Draft.js, built with React and leveraging a controlled ContentEditable component with immutable data structures, provides a more robust and customizable solution. The post highlights the framework's use in various Facebook products and its successful adoption by the open-source community, showcasing Meta's commitment to sharing developer tools.

2015

Open source in 2015: A year of growth

12/29/2015

This post highlights the significant growth and impact of Meta's open-source program in 2015. It details the increased adoption of key projects like React, HHVM, and Presto by external companies, the rapid rise of React Native and the introduction of Relay and GraphQL. The post emphasizes the substantial growth in community contributions, commits, stars, and forks, underscoring a strategic shift towards broader collaboration and external developer engagement.

HHVM support for PHP 7

12/4/2015

This post announces and details HHVM's support for PHP 7.0.0, including new language features like anonymous classes and generator delegation. It outlines the strategy for simultaneous support of PHP 5 and PHP 7, detailing how compatibility issues are handled through INI options and default behaviors. The post also commits to keeping HHVM in parity with future PHP language developments and solicits feedback on nightly builds to ensure a stable 3.11.0 release.

Relay: Declarative data for React applications

9/14/2015

Introduced Relay, a JavaScript framework for React applications that enables declarative data requirements. This allows for efficient batching of network requests, colocation of data requirements with rendering logic, and reduction of under-fetching and over-fetching, leading to fewer bugs and improved performance. Relay is currently in use at Facebook for web and mobile applications.

Writing code that writes code — with Hack Codegen

8/20/2015

Introduced Hack Codegen, a library for generating Hack code and writing it into signed files. This addresses issues with string concatenation for code generation, improves type safety, and reduces boilerplate by generating classes (like getters and mutators) from declarative schemas. It also introduces signed files to prevent manual modification of generated code and supports manual sections for flexibility.

The Parse SDK: What’s inside?

8/13/2015

This post details the internal architecture of the Parse SDK, highlighting the use of the Bolts framework for asynchronous programming (Tasks) to manage parallel and serial operations, and a decoupled architecture model (object instances, states, controllers) to ensure API consistency, testability, and extensibility. It showcases how these principles enable features like the Local Datastore by providing alternative controller implementations without breaking the public API.

Under the hood: Box’s HHVM migration

7/14/2015

Box successfully migrated their entire PHP codebase to HHVM, resulting in significant reductions in latency and increases in infrastructure capacity. The migration involved addressing numerous compatibility issues between HHVM and the standard PHP interpreter, including behavioral differences in less popular PHP corners and fundamental design choices like multiprocessing models and memory allocation. Box also revamped their deployment process to accommodate HHVM's JIT compilation warm-up requirements and the benefits of regular restarts. This involved a shift from a symlink-based deployment to a multi-instance HHVM setup that allows for warm-up, rollbacks, and canary deployments.

Announcing XHP-JS: Building efficient user interface components with Hack, React, and XHP

7/9/2015

Introduced XHP-JS, a library that enables the creation of efficient user interface components by combining Hack, React, and XHP. This allows for asynchronous server-side rendering with XHPAsync, integration of client-side logic into XHP components using XHPJSCall, and the creation of React components from Hack code using XHPReact. It also provides mechanisms for integrating existing non-XHP markup and Bootstrap components.

Fighting spam with Haskell

6/26/2015

This post details the migration of Facebook's Sigma spam detection system from an in-house FXL language to Haskell. Key technical contributions include the development of the Haxl framework to enable automatic batching and concurrent execution of data fetches, and the implementation of hot-swapping of compiled Haskell code for rapid deployment in a running production system. The post also discusses performance improvements achieved with Haskell over FXL, including a 20-30% increase in overall throughput, and optimizations made to the GHC compiler and heap management for multicore machines. It also highlights the use of Haskell's Foreign Function Interface (FFI) to integrate with existing C++ infrastructure.

Building Nuclide, a unified developer experience

6/23/2015

This post announces the open-sourcing of Nuclide, a unified developer experience built on GitHub's Atom editor. Nuclide provides packages for remote development over SSH, first-class support for Hack and Flow (including syntax highlighting, type-checking, autocomplete, and click-to-symbol features), Mercurial source control integration, and an omni-search tool. The goal is to improve developer efficiency for native iOS, React/React Native, and Hack/HHVM development by providing consistent tools across different stacks.

Futures for C++11 at Facebook

6/19/2015

This post introduces Folly Futures, a C++11 implementation of futures used at Facebook. It explains the benefits of asynchronous programming over synchronous programming for services, detailing how futures simplify the composition of asynchronous computations, both sequentially and in parallel. The post highlights the `then` and `collect` methods, discusses explicit control over execution contexts using an `Executor` interface, and explains how futures improve error handling compared to traditional callback-based approaches. It also covers how to create futures using `makeFuture` and `Promise`, and provides a case study of Instagram improving its recommendation service latency and robustness by adopting futures.

Open-sourcing Facebook Infer: Identify bugs before you ship

6/11/2015

This post introduces Facebook Infer, a static program analyzer open-sourced by Meta. It highlights the tool's ability to identify bugs (null pointer access, resource/memory leaks) before mobile code ships, significantly improving developer efficiency and product reliability. The post details the motivation for early bug detection on mobile, the novel techniques (separation logic, bi-abduction) used by Infer, and its history from academic research to a production tool used for billions of users.

Inside the HHVM lockdown

6/10/2015

This post details the results of HHVM's first performance lockdown, which focused on improving maximum requests per second. It highlights a 19% performance improvement in MediaWiki and discusses changes made to benchmarking tools and framework configurations. The post directs readers to the HHVM blog for more in-depth information on the lockdown, PHP results, and methodology.

HHVM adoption news

4/17/2015

This post details the adoption of HHVM by Box, Etsy, and Wikipedia, highlighting significant performance improvements. Box reported a halving of CPU utilization for their PHP application. Etsy achieved greater throughput on their API cluster and reduced server costs. Wikipedia saw approximately 2x faster results for editors after previews or edits. This demonstrates the broad impact of HHVM adoption on performance and efficiency across different organizations.

Mobile performance: Tooling infrastructure at Facebook

4/10/2015

This post introduces CT-Scan, a performance monitoring and prediction platform developed to address mobile performance regressions. It details the challenges of managing thousands of weekly code changes in complex mobile apps and outlines the design principles and implementation phases (development, staging, production) of CT-Scan. The post highlights the system's ability to detect, diagnose, and prevent performance regressions by capturing key metrics, performing statistical and machine learning analyses, and providing actionable insights to engineers, ultimately aiming to maintain development speed while improving app performance.

React Native: Bringing modern web techniques to mobile

3/26/2015

This post introduces React Native, a framework that brings modern web development techniques, specifically the declarative programming model of React, to native mobile application development (iOS and Android). It addresses the challenges of native mobile development by aiming to combine the user experience of native platforms with the developer experience of the web, enabling faster iteration cycles and a 'learn once, write anywhere' philosophy for engineers.

Introducing ComponentKit: Functional and declarative UI on iOS

3/25/2015

This post introduces ComponentKit, a new native Objective-C++ library for iOS that adopts a functional and declarative approach to UI development, inspired by React. It aims to simplify the creation of complex UIs like News Feed by abstracting away imperative coding, improving performance through background layout and intelligent view reuse, and enhancing maintainability and testability. The post also announces the open-sourcing of ComponentKit.

Stetho: A new debugging platform for Android

2/18/2015

This post introduces Stetho, an open-source Android debugging platform that bridges the gap between web developer tooling (like Chrome DevTools) and Android development. It enables richer access to application data, including network requests and custom data dumps, significantly improving the developer experience for Android engineers.

FAIR open sources deep-learning modules for Torch

1/16/2015

This post details the open-sourcing of optimized deep-learning modules for Torch by FAIR. It highlights significant performance improvements in convolutional neural networks (ConvNets) through FFT-based convolutions and GPU acceleration, as well as the introduction of modules for multi-GPU parallelization, optimized lookup tables, and faster temporal convolution layers. This release aims to accelerate AI research and development by providing the community with high-performance tools.

Inside Wikipedia’s transition to HHVM

1/7/2015

Details the collaboration with Wikipedia to transition their editing functionality to HHVM, resulting in a 45% reduction in median page save time and decreased CPU usage. This post highlights the performance benefits of HHVM for PHP-based applications, particularly for compute-intensive operations like page editing.

2014

12 Days of Open Source

12/8/2014

This post, "12 Days of Open Source," provides a year-end review of Meta's open-source contributions in 2014. It highlights the launch of 107 new projects, the popularity of iOS and JavaScript projects like React and Pop, the significant number of external developer contributions (over 1,000), and improvements in code review speed (average pull request age decreased by 3x). It also mentions contributions to security with osquery and Conceal, and participation in events like OSCON. This post significantly expands on Meta's open-source strategy and its impact on the broader engineering community.

Flow, a new static type checker for JavaScript

11/18/2014

Introduced Flow, an open-source static type checker for JavaScript, designed to improve developer productivity and code quality through early error detection and enhanced code intelligence. Flow utilizes advanced program analysis techniques (data-flow, control-flow) and an incrementally parallel type checking architecture for scalability. It supports opt-in typing, infers types automatically, and is compatible with ES6 features, JSX, and React applications. Flow is implemented in OCaml and aims to provide a seamless developer experience without disrupting the edit-run cycle.

Announcing the Hack Transpiler

11/11/2014

Introduced the Hack Transpiler (h2tp), an experimental tool to transpile Hack code to PHP. This allows projects that have adopted Hack to maintain backward compatibility with the PHP5 engine by generating PHP output alongside hacklib functions and classes. The tool handles type annotation erasure, short lambda expressions, and Hack collections, with specific considerations for reference semantics and boolean contexts. Limitations include the non-support of literal syntax for instance variables in class declarations.

@Scale 2014: Recap of Web Track

10/6/2014

This post details the adoption of HHVM by Wikipedia, resulting in a 50% reduction in rendering time and a 2x performance boost. It also covers Khan Academy's use of React for interactive learning interfaces and the open-sourcing of KaTeX and their live code editor. YouTube's adoption of WebP for image optimization led to 20-30% bandwidth reduction. Twitter discussed adaptable systems and UI components. Google presented advanced debugging techniques with Chrome DevTools and the introduction of Flow, a JavaScript type checker. Netflix shared insights into asynchronous programming.

@Scale 2014: Recap of Mobile Track

10/2/2014

This post details advancements in mobile development at Meta and across the industry, highlighting the challenges and solutions for building native mobile applications. It covers Facebook's iOS architecture (Components, custom persistence layer), Android development tools (Buck, Exopackage for faster builds), cross-platform development strategies (C++ with Djinni), and adaptations for emerging markets (fragmentation, device performance, data plans). It also touches upon the broader industry trends in mobile architecture and development.

Facebook, configuration management, community, and open source

10/1/2014

This post details Meta's evolution in configuration management, introducing a new data-driven framework built on Chef to manage their massive server infrastructure. It highlights a unique approach to cookbook design that prioritizes flexibility and ease of use, aiming to improve community cookbooks. The post also announces the open-sourcing of this framework, including example cookbooks and tools like Grocery Delivery and a new testing system, to share their learnings and contribute to the broader engineering community.

F8 Developer Conference – Hacker Way Recap

6/11/2014

This post details technical discussions from the F8 Developer Conference, including the introduction of Flux for single-directional data flow architecture, React for predictable UI development, the Hack programming language for bridging static and dynamic typing, and HHVM as a PHP runtime. It also covers mobile engineering at scale, tools for releasing and optimizing mobile apps, and the build tool Buck.

Open-sourcing Haxl, a library for Haskell

6/10/2014

This post introduces Haxl, a Haskell library designed to simplify and optimize access to remote data sources. Haxl automatically handles request batching, concurrent fetching from multiple sources, and caching, thereby improving the clarity and performance of data-fetching code. It leverages Haskell's Applicative Functors for implicit concurrency and provides soundness and modularity through its caching mechanism. The library is intended to be embedded within C/C++ applications via Haskell's foreign function interface.

Under the Hood: warp, a fast C and C++ preprocessor

3/28/2014

This post introduces 'warp', a fast C and C++ preprocessor open-sourced by Meta. It highlights how 'warp' significantly improves build times (10-40%) by optimizing preprocessing and include guard handling, directly impacting engineer productivity. The post details the technical motivations behind 'warp's' design, including its use of ranges and algorithms in D, and the importance of profiling and compiler optimizations for achieving high performance in development tools.

Hack: a new programming language for HHVM

3/20/2014

Introduced Hack, a new programming language for HHVM that interoperates seamlessly with PHP. Hack reconciles the fast development cycle of PHP with the discipline of static typing, incorporating features like generics, nullable types, type aliasing, and runtime enforcement of types. It also includes Collections for type-safe array alternatives and lambda expressions for concise closures. A key innovation is an instantaneous type checker that runs as a local server, providing sub-second feedback during development. The post also details the migration process and tools developed to convert PHP codebases to Hack, emphasizing its gradual typing nature and coexistence with PHP.

Building and open-sourcing Bolts, a mobile developer tools library

3/5/2014

This post introduces and explains Bolts, an open-source library of mobile developer tools from Parse + Facebook, with a focus on its 'Tasks' component. It details the challenges of asynchronous programming using analogies and explains how Tasks (similar to Promises) offer a more manageable and robust solution compared to traditional callbacks, particularly in Objective-C development by mitigating retain cycles and improving error propagation. This contributes to Meta's broader effort in providing advanced developer tools and promoting open-source contributions.

HHVM – Implementing MySQLi

3/3/2014

This post details the implementation of the MySQLi extension for HHVM. It covers the preparation phase, including rewriting the ini parser and leveraging HNI and docskel.php for extension development. The implementation involved passing through calls to older MySQL equivalents and using PHP to implement the procedural interface. Significant effort was put into testing, including updating the Zend import script to handle parallel test execution and modifying tests related to ZendParamMode. Roadblocks included implementing `mysqli_stmt::bind_param()` and `mysqli_stmt::bind_result()`, which required extensions to HNI for variable arguments and pass-by-reference. The implementation of `mysqli_multi_query()` and related functions was simplified by leveraging existing HHVM implementations. The post outlines the current test pass rate, real-world compatibility with Doctrine DBAL and CodeIgniter, and identifies missing pieces such as php.ini interaction, error message differences, MySQL Native Driver support, and behavioral differences. Future work includes supporting ZendParamMode for PHP functions in HNI and passing more failing Zend tests, with a planned release in HHVM 2.5.0.

Under the Hood: Building and open-sourcing flint

2/24/2014

This post introduces 'flint', Meta's custom C++ lint program, and details its development and open-sourcing. It highlights the challenges of C++ parsing, the decision to build a custom linter due to performance and feature limitations of existing tools, and the benefits of writing flint in the D language (faster builds, execution, and easier contribution). The post also enumerates 19 specific lint checks implemented in flint, demonstrating a focus on improving code quality and preventing common programming errors.

Under the Hood: Building and open-sourcing fbthrift

2/20/2014

This post details the evolution of Facebook's internal Thrift framework into fbthrift. Key technical contributions include the adoption of folly's IOBuf for efficient memory management with chained buffers, enabling out-of-order responses and reducing memory allocation overhead. A new THeader protocol was introduced to support per-request features and attributes without modifying core libraries, enhancing flexibility and backward compatibility. The release of fbthrift includes a new C++ code generator (cpp2) which has shown up to 50% latency reduction and significant memory footprint decreases in production services. The asynchronous C++ code is also a dependency for HHVM.

Scaling Mercurial at Facebook

1/7/2014

This post details Facebook's efforts to scale their source control system, Mercurial, to handle their massive codebase and rapid development pace. It highlights the decision to improve Mercurial over Git, the integration of Watchman for faster file status operations (over 5x faster than Git), and the development of the remotefilelog extension to make clones and pulls 10x faster by optimizing metadata and file content downloads. The post also emphasizes the open-sourcing of these extensions (hgwatchman and remotefilelog) and their positive impact on developer productivity.

2013

2013: A Year of Open Source at Facebook

12/20/2013

This post details Meta's significant expansion of its open-source contributions in 2013, highlighting new projects across mobile, web, data, and infrastructure. It showcases the release of tools like Buck, xctool, Rebound, Origami, React, Presto, RocksDB, and HHVM, emphasizing their impact on developer efficiency, performance, and community adoption. The post also outlines Meta's renewed commitment to maintaining these projects, fostering community engagement through improved tooling, bounties, the Facebook Open Academy, and the '@ Scale' event series.

Watchman: Faster builds with large source trees

5/30/2013

This post introduces Watchman, an open-source tool developed to significantly speed up build times for large source trees by enabling incremental processing of file changes. This directly addresses a bottleneck in the development workflow, allowing engineers to iterate faster and improving overall developer efficiency.

Speeding up the Activity social plugin

5/28/2013

This post details the significant performance optimization of the Activity social plugin, making it 5x lighter and nearly 2x faster by reducing static resource sizes, untangling dependencies, and improving packaging. It highlights a broader effort to optimize various social plugins for better page-loading performance.

Buck: How we build Android apps at Facebook

5/15/2013

Introduced Buck, a new build system for Android, to address slow build times and complexity associated with Ant and Android library projects. Buck favors the creation of many small modules, leading to fine-grained dependencies and significantly faster build times (from 3m40s to 1m30s). It also simplifies code reuse across multiple Android apps built from a single codebase and enables faster iteration by allowing quick building of small sample applications.

LinkBench: A database benchmark for the social graph

4/1/2013

This post introduces LinkBench, a new database benchmark specifically designed for the social graph workload. It details the challenges of benchmarking graph-structured data, explains the design and architecture of LinkBench, and presents initial benchmark results on MySQL. This contributes to the broader theme of optimizing database infrastructure and evaluating new systems for Facebook's production workloads.

Three Optimization Tips for C++

3/15/2013

This post provides practical optimization tips for C++ code, focusing on techniques beyond basic algorithmic improvements. It introduces concepts like strength reduction, minimizing array writes, and using lookup tables for faster string conversions. The post emphasizes the importance of measurement and understanding modern CPU architectures to achieve significant performance gains in computationally intensive tasks.

Under the Hood: Dalvik patch for Facebook for Android

3/4/2013

This post details a significant engineering challenge and solution related to the Android application's performance and compatibility on older devices. It describes how a large number of Java methods, resulting from a rebuild of the Android app, exceeded the LinearAlloc buffer limitations in older Android versions (Froyo and Gingerbread). The engineering team developed a complex JNI extension to patch the Dalvik Virtual Machine by increasing the LinearAlloc buffer size, enabling the app to run on a wider range of devices and preventing feature cuts.

Like Box plugin: Now 2-4x faster

2/26/2013

This post details the significant performance improvements made to the Like Box plugin, achieving 2-4x faster load times. Key contributions include simplifying and reducing the size of components, inlining CSS for faster initial rendering, reducing JavaScript size, and implementing asynchronous, non-blocking JavaScript loading. These optimizations drastically decreased the number of resources, total payload size, and improved perceived performance by accelerating the first browser paint.

2012

Under the Hood: Rebuilding Facebook for Android

12/13/2012

This post details the significant re-architecture of the Facebook for Android application, moving from a hybrid native/webview approach to pure native code. It highlights the performance challenges encountered and the custom solutions developed, including reducing garbage collection, writing a custom event bus, optimizing photo loading by moving bitmaps to the native heap, and creating a custom ListView recycler. These efforts were aimed at improving speed, reliability, and user interface smoothness for the Android app.

Under the Hood: The JavaScript SDK – Truly Asynchronous Loading

12/8/2012

Introduced and implemented the FIF (Friendly iFrames) technique for the Facebook JavaScript SDK to achieve truly asynchronous loading. This technique involves loading the SDK within an iframe and triggering its `onload` event to avoid blocking the parent page's `window.onload` event. The post also details how to adapt existing JavaScript code to work within this iframe context by passing the parent `window` object and explains the integration with the `inDapIF` global variable for SDK compatibility.

Speeding up PHP-based development with HipHop VM

11/29/2012

This post details the evolution of HipHop VM (HHVM) as a successor to HPHPc, focusing on its JIT compilation approach. It highlights HHVM achieving parity with HPHPc in performance for Facebook's codebase, reducing development environment load times by over 3x compared to HPHPi, and unifying production and development environments. Technical deep dives cover improvements to the JIT compiler, including adding JIT support for less common instructions (like member instructions for array/object access), implementing 'side exits' to handle rare conditions that could affect correctness, and using type prediction for method call return types to create longer, more efficient tracelets. The post also mentions ongoing open-source efforts and plans for broader PHP codebase compatibility.

Under the Hood: The JavaScript SDK – The use of polyfills

11/20/2012

This post details Meta's approach to handling JavaScript cross-browser compatibility for its SDK by transpiling ES5 code to ES3, thereby avoiding the use of traditional polyfills. It explains the risks associated with polyfills modifying the global runtime and introduces a source transformation process using jsgrep's 'jspatch' to convert ES5 features into calls to a custom 'ES5' function. This function acts as a proxy, ensuring that ES5 features are safely invoked without polluting the global scope or altering built-in objects, thus maintaining compatibility with older browsers and third-party pages.

Under the Hood: The JavaScript SDK – error handling

11/1/2012

This post details the implementation of advanced error handling within Meta's JavaScript SDK. It introduces a `guard` function to wrap arbitrary functions, catching and logging unmanaged errors while re-throwing custom `ManagedError` types. The post also covers techniques for instrumenting entry points like `setTimeout`, event handlers, and callbacks, as well as handling errors in external function invocations and returned functions. A strategy for differentiating internal and external callers to avoid redundant error logging and prevent monkey-patching side effects is also presented.

Building the WordPress plugin

9/26/2012

This post details the technical development and challenges encountered while building the Facebook for WordPress plugin. It highlights the integration of Open Graph actions (news.publish), the resolution of issues related to cURL dependencies by leveraging WordPress's abstractions, handling PHP SDK namespace collisions and versioning, and updating the SDK to support extending short-lived access tokens. The post also emphasizes the collaborative effort with the WordPress community and the decision to open-source the plugin.

Timed releases for mobile apps

9/20/2012

This post details the adaptation of Facebook's web release process for mobile applications (Android and iOS). It introduces a date-driven release model, moving away from feature-driven development to enable predictable release cycles (4-8 weeks). This approach prioritizes stability and performance updates, allowing them to ship independently of feature completion. The post also highlights the unique challenges of mobile releases, such as higher stakes for crashes and the inability to perform gradual rollouts, necessitating a higher quality bar and careful scrutiny of changes. It also mentions code and test reuse across platforms (e.g., main Facebook app and Messenger app on iOS/Android) to improve efficiency.

Under the hood: Rebuilding Facebook for iOS

8/23/2012

This post details a significant shift in Facebook's mobile development strategy, specifically for iOS. It marks the abandonment of the Three20 framework and a move away from HTML5 for core mobile experiences towards a complete rewrite of the Facebook for iOS app using native Objective-C. Key contributions include: detailing the performance optimizations achieved through background processing, asynchronous operations, and efficient UI layout calculations; introducing a modular architecture for incorporating features like Facebook Messenger; and outlining a 'fallback' renderer strategy to enable rapid feature iteration without immediate app updates. This post represents a strategic pivot towards native platform depth and modularity in mobile development.

Folly: The Facebook Open Source Library

6/2/2012

Introduced Folly, a collection of reusable C++ library artifacts developed and used at Facebook, to address the bottleneck of releasing open-source projects due to dependencies on unreleased internal library code. Folly components are designed for high performance at scale, with examples like AtomicHashMap demonstrating wait-free lookups and fine-grained locking for insertions to reduce contention. The library also focuses on programmer convenience and performance with utilities like folly::to and folly::format for string manipulation, and complements existing libraries like Boost and the Standard Library.

Back-end build systems and toolchain: Adam Simpkins

5/15/2012

This post introduces fbconfig as a tool for building back-end services, simplifying project creation and code sharing by abstracting compilation and dependency management. It also highlights ongoing work on the HTTP stack and load balancing infrastructure to improve network speed and efficiency, including support for SPDY and optimized load balancing mechanisms.

Under the Hood: Mobile Timeline

1/19/2012

This post details the engineering challenges and solutions for building the mobile version of Facebook's Timeline feature. It highlights the need for a rewritten mobile experience with new designs for smaller viewports, device-specific styling, and touch interactions. Key contributions include the development of adaptive hardware acceleration for smooth scrolling, a JavaScript swiping component for horizontal navigation and content browsing, and an optimized approach to image loading and rendering for higher-definition images tailored to device pixel density, all while aiming to minimize bandwidth usage.

Meet a Facebook Engineer: Keith Adams

1/6/2012

This post details the development of the search typeahead backend, which powers Facebook's search box. It highlights the invention of custom data structures for the index and discusses the ongoing work on the HipHop Virtual Machine (HHVM) to combine high performance with the interactivity of interpreted languages like PHP. The engineer also shares insights on the importance of developer productivity languages and the need for engineers to take calculated risks in software development.

Building Timeline: Scaling up to hold your life story

1/5/2012

This post details the engineering effort behind Facebook's Timeline feature, highlighting the challenges and solutions for scaling to store and present years of user activity. It describes the denormalization of data for efficient ranking, the development of a Timeline aggregator built on Multifeed, and a highly parallelized development process that started as a hackathon project. It showcases the application of core Facebook technologies (MySQL, Multifeed, Thrift, memcached) to a complex data aggregation and presentation problem.

2011

Meet a Facebook Fellow: Marek Olszewski

12/15/2011

This post introduces Marek Olszewski, a Facebook Fellow, and his research on Kendo, a software-only prototype system providing a deterministic multithreading programming model. Kendo aims to simplify parallel application development and debugging by enforcing deterministic interleaving of synchronization operations. The post also highlights the connection of this research to Hip Hop VM and the "get it done" engineering culture at Facebook.

The HipHop Virtual Machine

12/9/2011

Introduced the HipHop Virtual Machine (HHVM) as a dynamic translation engine for PHP, offering a faster alternative to the HipHop interpreter (hphpi) and aiming to eventually replace static compilation for all PHP execution. HHVM uses a high-level stack-based virtual machine executing HipHop Bytecode (HHBC) and employs a 'tracelet' approach for JIT compilation, limiting traces to single basic blocks with type guards. This approach showed significant performance gains over hphpi and is expected to approach or exceed static compilation performance.

Making HPHPi Faster

10/18/2011

This post details several optimizations made to the HPHPi interpreter to improve its performance. These include: sharing parse trees across sandboxes to reduce parsing time and memory usage, moving PHP file parsing out of a critical region to enable parallel parsing, AST node specialization (e.g., for increment/decrement operations) to reduce node size and speed up operations, caching pointers to built-in function metadata to avoid hash table lookups, precomputing static values and scalar arrays, preprocessing AST nodes for frequently evaluated expressions, type prediction to bypass overloaded operators for common types, improving hash table lookups by using HipHop's StringIMap/StringMap and making StaticStrings unique, making common function calls faster by avoiding argument array packing for up to 6 arguments, and enabling unit tests to run in server mode for parallel execution and parse tree reuse. These optimizations resulted in a 53.6% increase in speed for the bench.php benchmark.

Visualizing Facebook’s PHP Codebase

5/31/2011

This post details the development of a novel, interactive visualization tool to understand the interdependencies within Facebook's large-scale PHP codebase (over 10,000 modules). The visualization uses a layered approach, coloring modules by dependency count, and provides interactive exploration of direct and transitive dependencies. This tool was developed as a Hackathon project to address the complexity of visualizing such a large system, offering insights into module granularity and dependency management.

One Mobile Site to Serve Thousands of Phones

3/31/2011

This post details a major upgrade to m.facebook.com, unifying the mobile web experience by moving from multiple device-specific mobile sites (m.facebook.com and touch.facebook.com) to a single, adaptive framework. This new approach uses XHP, Javelin, and WURFL to dynamically serve the best possible experience for thousands of different mobile devices, enabling faster feature development and consistent feature availability across all mobile platforms.

HipHop for PHP: More Optimizations for Efficient Servers

3/30/2011

This post details further optimizations to HipHop for PHP, building on its initial adoption. Key improvements include: reducing serialization/unserialization costs in APC, optimizing JSON encoding, minimizing reference counting operations, creating more compact binary code to improve instruction cache performance, enhancing memory allocation with jemalloc, and speeding up the compilation process through parallelization and community contributions. These changes resulted in a 70% increase in web server throughput on the same hardware.

Hybrid Incremental MySQL Backups

3/1/2011

This post details significant improvements to Facebook's database backup system, transitioning from slow logical backups (mysqldump) to faster, more efficient physical backups using an enhanced XtraBackup tool. Key contributions include the development of hybrid incremental backup strategies to optimize IO calls and avoid reading unmodified pages, the implementation of table-level restore for faster recovery of individual tables, and performance optimizations for both full and incremental backups through adjusted IO sizes. These enhancements drastically reduce backup times and server load while maintaining data reliability.

Scalable memory allocation using jemalloc

1/3/2011

This post details the integration and enhancement of jemalloc, a memory allocator, to address critical challenges in Facebook's server applications. It highlights improvements in allocation speed, consistency of RAM usage by reducing fragmentation, and enhanced memory heap profiling capabilities. The post outlines core jemalloc algorithms and data structures, and details Facebook-motivated innovations focused on speed (rewriting thread caching, increasing mutex granularity, optimizing dirty page purging, and developing a new red-black tree implementation) and introspection (exposing statistics via mallctl* API).

2010

HipHop for PHP: six months later

8/13/2010

This post provides an update on HipHop for PHP six months after its release. It highlights a further 1.8x speed improvement, bringing the total reduction in CPU usage to approximately 50% compared to the initial release. It details successful integration with Drupal, MediaWiki, phpBB, and WordPress, noting significant speedups for WordPress (2.7x). The post also mentions community contributions, including external patches and support for FreeBSD and 32-bit environments, indicating growing community involvement and the project's expansion beyond Facebook's internal use.

Scaling Facebook to 500 Million Users and Beyond

7/21/2010

This post, 'Scaling Facebook to 500 Million Users and Beyond,' details the engineering and operational principles employed to manage exponential user growth. It highlights key strategies such as horizontal scaling, moving fast, changing incrementally, measuring everything, empowering small independent teams, and ensuring control and responsibility for engineers. The post provides concrete metrics of Facebook's scale (500 million users, 100 billion hits/day, 50 billion photos) and emphasizes that these scaling principles are crucial for future growth beyond the 500 million user milestone.

BigPipe: Pipelining web pages for high performance

6/4/2010

This post introduces BigPipe, a fundamental redesign of the dynamic web page serving system. It addresses the inefficiencies of the traditional sequential model by decomposing web pages into pagelets and pipelining their generation and rendering across web servers and browsers. This allows for overlapping execution stages, significantly reducing end-to-end and perceived latency, as demonstrated by a 50% reduction in user perceived latency for key content.

Protecting Privacy with Referrers

5/25/2010

This post details Facebook's proactive efforts to protect user privacy by controlling the information sent in HTTP referrer headers to external websites, specifically advertisers. It addresses an issue where user IDs could be unintentionally exposed and outlines the technical implementation of a redirector system designed to remove user IDs from referrer URLs across various browsers, demonstrating a commitment to going beyond industry standards for privacy protection.

Intro to Facebook Search

3/16/2010

This post introduces Facebook Search, detailing its evolution from a basic search function to a sophisticated, user-centric system. It explains the complexities of serving over 150 million queries daily and the decision to build an in-house search service. Key technical challenges discussed include: ranking on the critical path due to the need for real-time personal and social context, the absence of traditional query caching due to the unique [user, query] nature of requests, maintaining a large 'hot' index because most results are relevant to specific users, and the necessity of live updates to reflect constant user profile and connection changes. The post also highlights the growing use of search for discovering entities beyond people, such as bands and applications, and the infrastructure challenges of indexing and filtering recent public and friend content.

Making Facebook 2x Faster

2/19/2010

This post details Facebook's initiative to make the site twice as fast by focusing on reducing network and render times. It introduces key performance metrics like Time-to-Interact (TTI) and outlines strategies implemented, including reducing cookie, HTML, and CSS bytes through reusable components (built on XHP), and drastically cutting JavaScript bytes with the Primer library. It also introduces the BigPipe system for pipelining content generation and rendering, which successfully achieved the goal of doubling site speed.

XHP: A New Way to Write PHP

2/10/2010

Introduced XHP, a PHP extension that augments PHP syntax to make front-end code easier to understand and prevent cross-site scripting attacks by treating XML document fragments natively within PHP. XHP provides context-specific escaping for PCDATA, server-side parse-time error detection for malformed markup, and allows for the definition of custom elements to condense complex components into simple XHP tags, acting as a programmatic UI library and a templating system.

Site Reliability Engineering at Facebook

2/8/2010

This post introduces the concept and function of Site Reliability Engineering (SRE) at Facebook. It details the SRE team's responsibilities in ensuring the site is always up, performing at its peak, and that all features are functional for over 400 million users. The post highlights the SRE team's role in managing high traffic loads, troubleshooting operational issues, coordinating code updates with Release Engineering, and developing tools for server management and performance optimization, including work on the memcached footprint. It emphasizes the SRE team's significant impact and the fast-paced, dynamic nature of their work.

HipHop for PHP: Move Fast

2/2/2010

Introduced HipHop for PHP, a source code transformer that converts PHP to highly optimized C++ for compilation. This significantly reduces CPU usage (average 50%) and server overhead, enabling faster iteration and scaling of complex PHP applications. It includes a code transformer, a reimplementation of PHP's runtime system, and rewrites of common PHP extensions. Also developed HPHPi, an experimental interpreter for development to catch bugs and provide a seamless development experience.

2009

Real-World Web Application Benchmarking

12/17/2009

This post introduces 'Dyno', a proprietary capacity testing methodology developed by Facebook to benchmark application performance under real-world conditions, contrasting it with industry-standard benchmarks. It details the evaluation of Intel's Nehalem/Tylersburg architecture against the previous Harpertown/San Clemente platform, revealing a 62% increase in request throughput and a 44% improvement in performance-per-watt. The post emphasizes the importance of considering performance per watt for overall Total Cost of Ownership (TCO) and advocates for accurate workload profiling when evaluating new technologies.

Reducing markup size

9/1/2009

This post details the optimization of the Universal Feedback Interface (UFI), particularly the Like feature, to reduce its markup size. It describes the initial approach of sending redundant markup and the subsequent shift to an asynchronous update mechanism, highlighting the trade-offs between markup savings and user experience. The post quantifies the impact, showing a 20-kilobyte reduction in the average home.php page size, contributing to an 8% slimmer homepage.

Every Millisecond Counts

8/28/2009

This post significantly contributes to the understanding of how micro-optimizations in site speed directly impact user behavior. It presents experimental findings on the effects of site slowdowns on session time and page views, resolves a debate on page rendering strategies by demonstrating the negative impact of blank pages, and validates the effectiveness of scroll loading for News Feed by showing increased usage statistics, especially among casual users, when more content is loaded progressively.

Designing the Facebook username land rush

8/12/2009

This post details the design and implementation of the username system, focusing on scaling the availability checker and username assigner using a memcache tier as the authoritative source for availability checks, implementing fault tolerance mechanisms, and conducting extensive load testing and contingency planning for a high-traffic launch. This also highlights the use of Scribe for logging and real-time data collection.

Hammering Usernames

7/2/2009

This post details the engineering challenges and solutions for the large-scale launch of Facebook usernames. It highlights the critical role of the Memcached infrastructure, which was expanded and dedicated to handle username availability checks and blocked names. The post also elaborates on the Site Reliability Engineering (SRE) approach, including 'dark launching' for pre-launch stress testing, and the implementation of dynamic 'levers' and 'nuclear options' to manage traffic load and ensure site stability during the unprecedented username registration event.

Adapting Open Source Software

4/11/2009

This post details Facebook's strategic use and adaptation of open-source software such as PHP, MySQL, and Memcache, including specific optimizations and modifications. It also highlights contributions back to the community through projects like Thrift and Scribe. The post provides an overview of the services stack, including custom backend services for NewsFeed and Search, and the tooling that facilitates development, deployment, monitoring, and maintenance of code written in diverse languages like C++ and Erlang.

Scaling Facebook Live Feed for the Inauguration

4/8/2009

This post details the engineering challenges and solutions for scaling the Facebook Live Feed during the 2009 Presidential Inauguration. It highlights strategies for handling millions of concurrent users and high request rates, including dynamic generation of 'Friends' feeds, aggressive caching of 'Everyone' feeds using memcache and CDNs, and the development of numerous 'levers' for capacity management. The post also emphasizes the importance of extensive load testing and 'dark launches' to ensure stability during the critical event.

XHProfLive: Continuous function-level performance stats from production

4/3/2009

This post introduces XHProfLive, a system for collecting and analyzing continuous function-level performance statistics from production. It addresses the need for near real-time, detailed performance data to pinpoint regressions. The post highlights the development of XHProf, a lightweight instrumentation-based callgraph profiler, and its integration into XHProfLive for aggregating and visualizing performance data. It also announces the open-sourcing of XHProf, making this powerful profiling tool available to the wider community.

2008

Scaling memcached at Facebook

12/12/2008

This post details critical scaling challenges and solutions for memcached, Facebook's largest user of the system. It highlights modifications made to the operating system and memcached to address memory inefficiencies from per-connection buffers, improve UDP performance through per-thread sockets, distribute network I/O across cores with opportunistic polling, and resolve contention issues in stat collection and network transmit queues. These changes significantly boosted memcached's performance, enabling it to handle much higher request rates and lower latency, and led to the release of these modifications on GitHub.

Scaling Out

8/20/2008

This post details the engineering challenges and solutions involved in establishing a second datacenter on the East Coast. It explains the need for this expansion due to latency, space, and disaster recovery concerns. The core technical contributions described are the implementation of a modified MySQL replication stream to handle cache consistency issues with secondary datacenters and the use of load balancers and cookies to manage traffic routing and ensure data consistency for users across different datacenters.

Welcome to the Facebook Engineering Blog!

5/14/2008

This post announces the launch of the Facebook Engineering Blog, establishing it as a space for sharing technical details, architecture discussions, and code samples related to Facebook's systems. It aims to provide insights into scaling and user experience, with a promise to cover various engineering topics.