# 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. ## Install Save as a script file and run: # Folly — Facebook's High-Performance C++ Foundation Library ## Quick Use ```bash git clone https://github.com/facebook/folly.git cd folly mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release make -j$(nproc) sudo make install ``` ## 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 - https://github.com/facebook/folly - https://github.com/facebook/folly/tree/main/folly/docs --- Source: https://tokrepo.com/en/workflows/asset-85688bf6 Author: Script Depot