Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsJul 6, 2026·3 min de lecture

Folly — Facebook's High-Performance C++ Foundation Library

Folly is Facebook's open-source C++ library providing core utilities for large-scale systems including futures, concurrency primitives, string handling, and memory management. It complements the C++ standard library with production-tested components optimized for performance.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Folly Overview
Commande d'installation directe
npx -y tokrepo@latest install 85688bf6-7978-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

Introduction

Folly (Facebook Open Source Library) is an open-source C++ library developed at Meta that provides core building blocks for high-performance systems programming. It supplements the C++ standard library with components that have been hardened through years of production use at one of the world's largest-scale infrastructures.

What Folly Does

  • Provides high-performance concurrent data structures like ConcurrentHashMap, AtomicHashMap, and lock-free queues
  • Implements a futures and promises framework (folly::Future) for composable asynchronous programming
  • Offers optimized string utilities including fbstring (a drop-in std::string replacement) and fbvector
  • Supplies memory allocation helpers, custom allocators, and arena-based allocation for latency-sensitive code
  • Includes IO utilities such as IOBuf for zero-copy buffer management and AsyncSocket for event-driven networking

Architecture Overview

Folly is organized as a modular collection of largely independent components built on top of C++17. Each module addresses a specific systems-programming concern, from low-level bit manipulation and hardware intrinsics up through higher-level abstractions like EventBase for event loops and Executor for task scheduling. The library relies on a thin portability layer to support Linux, macOS, and Windows, and integrates with other Meta open-source projects like Fizz (TLS) and Wangle (networking framework).

Self-Hosting & Configuration

  • Build requires CMake 3.0.2+, a C++17-capable compiler (GCC 7+ or Clang 6+), Boost, and several system libraries
  • Install dependencies on Ubuntu: sudo apt install libboost-all-dev libevent-dev libdouble-conversion-dev libgoogle-glog-dev libgflags-dev
  • Use -DBUILD_SHARED_LIBS=ON to produce shared libraries instead of static
  • Individual components can be consumed via find_package(folly) after installation
  • Vcpkg and Conan packages are available for cross-platform dependency management

Key Features

  • Battle-tested at Meta scale across billions of requests per day
  • Optimized fbstring implementation with small-string optimization and copy-on-write semantics
  • folly::Future provides a composable async model with .then() chaining and executor awareness
  • IOBuf enables zero-copy networking with reference-counted buffer chains
  • Comprehensive benchmarking utilities (folly::Benchmark) for micro-benchmarking C++ code

Comparison with Similar Tools

  • Abseil (Google) — focuses on standard-library extensions with ABI stability; Folly targets raw performance with less ABI concern
  • Boost — broader scope and committee-track focus; Folly is more opinionated and Meta-specific
  • POCO — provides higher-level application frameworks; Folly stays closer to systems-level primitives
  • libcds — specializes in concurrent data structures; Folly offers concurrency plus general utilities
  • Intel TBB — focuses on parallelism and task scheduling; Folly covers a wider utility surface

FAQ

Q: Does Folly require the entire library to be linked? A: No. Folly is modular, and you can link only the components you need via CMake targets such as Folly::folly or individual sub-libraries.

Q: Is Folly ABI-stable? A: Folly does not guarantee ABI stability across releases. It is designed to be built from source alongside your project.

Q: What platforms does Folly support? A: Folly officially supports Linux (primary), macOS, and Windows. Linux receives the most testing and optimization.

Q: How does folly::Future differ from std::future? A: folly::Future supports .then() continuation chaining, executor-based scheduling, and composability features like collectAll that std::future lacks.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires