Folly: The Facebook Open Source Library

Visit the post for more.

Jordan DeLong
4 min readintermediate
--
View Original

Overview

Folly is an open-source C++ library developed by Facebook to enhance performance and usability in their services. This library addresses the challenges of releasing open-source projects by providing high-performance, reusable components that complement existing libraries.

What You'll Learn

1

How to utilize Folly for high-performance C++ applications

2

Why Folly components outperform existing C++ libraries

3

When to apply Folly's string utilities for better performance

Prerequisites & Requirements

  • Understanding of C++ programming concepts
  • Experience with high-performance computing(optional)

Key Questions Answered

What is Folly and why was it developed?
Folly is an open-source C++ library created by Facebook to address the bottleneck of releasing open-source projects that depend on internal libraries. It allows developers to use high-performance components without reinventing existing solutions.
How does Folly enhance performance in C++ applications?
Folly includes utilities like AtomicHashMap, designed for high concurrency with wait-free lookups and fine-grained locking for insertions. This design significantly reduces contention-related performance bottlenecks in services handling large, concurrent in-memory indexes.
What advantages do Folly's string utilities provide?
Folly's string utilities, such as folly::to and folly::format, are designed to be faster and safer than alternatives like boost::lexical_cast and iostream manipulators. They optimize CPU usage and improve code brevity, making string manipulation more efficient.
How does Folly complement existing C++ libraries?
Folly is designed to work alongside high-quality libraries like Boost and the Standard Library. It addresses specific performance issues encountered with existing solutions, providing modern alternatives that enhance developer productivity.

Key Statistics & Figures

Number of users supported by Facebook services using Folly
900 million
Folly's utilities are used in production on thousands of servers to support this vast user base.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Key Actionable Insights

1
Incorporate Folly's components into your C++ projects to enhance performance and reduce development time.
Using Folly can help avoid the pitfalls of reinventing the wheel, allowing you to leverage high-performance utilities that are already optimized for scale.
2
Utilize Folly's string manipulation utilities to improve the efficiency of your code.
Since many applications spend significant CPU time on string operations, adopting Folly's optimized utilities can lead to noticeable performance gains.
3
Explore the ongoing updates to Folly to stay current with new components and improvements.
Folly is actively maintained, and keeping up with its updates can provide you with new tools and enhancements that could benefit your projects.

Common Pitfalls

1
Relying solely on existing libraries without evaluating performance can lead to bottlenecks.
Many developers may overlook the specific needs of their applications, resulting in inefficiencies. It's crucial to assess whether existing solutions meet performance requirements before implementation.

Related Concepts

High-performance Computing
C++ Programming
Open-source Software Development