For a high level overview see the README
Below is a list of (some) Folly components in alphabetical order, along with a brief description of each.
Simple arena for memory allocation: multiple allocations get freed all at once. With threaded version.
High-performance atomic data-structures. Many of these are built with very specific tradeoffs and constraints in mind that make them faster than their more general counterparts. Each header should contain information about what these tradeoffs are.
A Baton allows a thread to block once and be awoken: it captures a single handoff. It is
essentially a (very small, very fast) semaphore that supports only a single call to
A small framework for benchmarking code. Client code registers benchmarks, optionally with an argument that dictates the scale of the benchmark (iterations, working set size etc). The framework runs benchmarks (subject to a command-line flag) and produces formatted output with timing information.
Various bit manipulation utilities optimized for speed; includes functions that wrap the ffsl(l) primitives in a uniform interface.
An implementation of the structure described in A Provably Correct Scalable Concurrent Skip List by Herlihy et al.
A variety of data conversion routines (notably to and from string), optimized for speed and safety.
Pretty-printing C++ types.
boost::variant, but restricted to pointers only. Uses the
highest-order unused 16 bits in a pointer as discriminator. So
sizeof(DiscriminatedPtr<int, string, Widget>) == sizeof(void*).
Dynamically-typed object, created with JSON objects in mind.
a utility for effeciently converting from a
dynamic to a more concrete structure when
the scheme is known (e.g. json ->
A simple LRU hash map.
A drop-in implementation of
std::string with a variety of optimizations.
A mostly drop-in implementation of
std::vector with a variety of
A C++ abstraction around files.
A polymorphic wrapper for callables similar to
std::function but not copyable and therefore able to wrap non-copyable callables, such as lambdas that capture move-only types like
Futures is a framework for expressing asynchronous code in C++ using the Promise/Future pattern.
Python-style formatting utilities.
This library makes it possible to write declarative comprehensions for processing sequences of values efficiently in C++ akin to C#'s LINQ.
Group Varint encoding for 32-bit values.
A collection of utilities to deal with IPAddresses, including ipv4 and ipv6.
A collection of useful of abstractions for high-performance io. This is heavily relied upon in Facebook's internally networking code.
Various popular hash function implementations.
A simple class for collecting histogram data.
Convenience type definitions for using
JSON serializer and deserializer. Uses
Memory allocation helpers, particularly when using jemalloc.
A really, really small spinlock for fine-grained locking of lots of teeny-tiny data.
MPMCQueue is a high-performance bounded concurrent queue that supports multiple producers, multiple consumers, and optional blocking. The queue has a fixed capacity, for which all memory will be allocated up front.
The additional utility
MPMCPipeline.h is an extension that lets you
chain several queues together with processing steps in between.
A highly specialized data structure consisting of a pointer, a 1-bit spin lock, and a 15-bit integral, all inside one 64-bit word.
Necessarily evil stuff.
Lock free single-reader, single-writer queue.
Defines only one function---
Boost-style range facility and the
Fast and compact reader-writer spin lock.
C++11 incarnation of the old ScopeGuard idiom.
A singleton to rule the singletons. This is an attempt to insert a layer between
C++ statics and the fiasco that ensues, so that things can be created, and destroyed,
correctly upon program creation, program end and sometimes
Singletons are bad for you, but this may help.
Very small spin locks (1 byte and 1 bit).
Vector with the small buffer optimization and an optional embedded
Collections similar to
std::map but implemented as sorted vectors.
A collection of efficient utilities for collecting statistics (often of time series data).
STL allocator wrapping a simple allocate/deallocate interface.
String utilities that connect
Subprocess library, modeled after Python's subprocess module.
High-level synchronization library.
Demangling and errno utilities.
High-performance atomic increment using thread caching.
Improved thread local storage for non-trivial types.
Queue with per-item timeout.
Type traits that complement those defined in the standard C++11 header
A collection of utilities to deal with URIs.