$ show facebook/folly
Folly is a mature C++20 component library from Meta, not an end-user application. It provides high-performance primitives for systems programming: containers (F14 hash maps, small_vector, sorted_vector_types), string and JSON handling, concurrency (MPMCQueue, AtomicHashMap, Synchronized), async I/O (EventBase, AsyncSocket, AsyncServerSocket, SSLContext, io_uring integration), multiple async programming models (futures, fibers, coroutines), logging, settings, memory allocation, debugging/symbolization, hashing, compression, and statistics. Consumers embed the library via CMake or Buck2 and link libfolly; there is no standalone service or primary CLI except tools, tests, and examples. Internally, the architecture is strongly modular and header-first: most components are templates in header files with optional .cpp implementations, heavily gated on platform feature macros. Data flows are data-structure and callback oriented: events from sockets/timers are dispatched through EventBase, async results move through Future/SemiFuture/coro::Task continuations, fibers perform cooperative context switches, and the logging framework routes formatted log messages through configurable handlers. External dependencies include Boost, OpenSSL, libevent, fmt, zstd/lz4/zlib, and googletest for testing; the repo includes a dependency builder (getdeps.py) and CI for Linux/macOS/Windows. Folly is actively maintained with frequent commits, broad CI, and extensive test/benchmark suites. Some parts are experimental (folly::result, channels), but core components are production-tested. Technical drift is low: it tracks modern C++, supports current compilers and kernels, and adapts to new CPU features (AVX-512, SVE2, io_uring). A small internal Python-based agent backtesting kit exists under folly/agents/, but it is peripheral; the dominant character of the repository is a high-performance C++ library.
The LLM identified 6 files worth highlighting for reuse:
F14Map is a fast, memory-efficient open-addressing hash map with SIMD-powered chunked probing (14 slots per chunk). It provides reference stability, excellent cache locality, and a portable fallback implementation for platforms without SIMD. The public header demonstrates advanced hash-table engineering and is a standalone component that can be reused or studied independently.
A bounded multi-producer/multi-consumer queue implemented with atomic sequence numbers and careful cache-line layout. It provides blocking and non-blocking FIFO operations and is a model of lock-free queue design. Header-only and nearly dependency-free, it can be extracted into any C++ project.
High-performance thread-local storage with per-thread instances, automatic cleanup, and accessor objects. It solves recurring concurrent-caching problems and avoids the cost and limitations of native thread_local for many elements. Designed as a reusable header, it demonstrates careful attention to lifetime and cache behavior.
A compressed approximate-membership data structure built on quotienting and rank/select operations. It offers a compact alternative to Bloom filters for certain workloads and showcases sophisticated bit-level engineering. The implementation is self-contained and suitable for reuse in storage, networking, and database-style systems.
A merging T-Digest implementation for accurate online estimation of percentiles from large or streaming data. It is self-contained and parameterized, making it reusable for telemetry, profiling, and data-science tooling. It demonstrates non-obvious statistical craftsmanship and careful numerical behavior.
SIMD-accelerated any_of for integral types, using compile-time dispatch, explicit unrolling, and portable vector abstractions. Although placed in a detail namespace, it is small, dependency-light, and can be extracted into performance-critical code or used as a reference for portable SIMD algorithm design.