SYSTEM Cited by 1 source
folly::Singleton¶
folly::Singleton is Meta's canonical C++ singleton primitive
in folly. Source:
folly/Singleton.h.
Cited in the 2024-12-02
cryptographic monitoring post as "Meta's go-to library for managing
singletons."
The post surfaces folly::Singleton specifically in the context of
job shutdown: FBCrypto's aggregating buffered logger must do
"one final flush to log all remaining contents of their log buffer
to Scribe when a job is being shut down" — and Meta notes that
"operating in a shutdown environment can lead to a number of
interesting scenarios, particularly when attempting to access Scribe
and its dependencies. Many of these scenarios boil down to the
nuances of folly::Singleton."
Role for this wiki¶
- Canonical Meta singleton primitive. Any Meta-internal C++
service with a process-wide global typically sits on
folly::Singletonfor initialization-order + shutdown-order correctness. - Shutdown-correctness substrate. The reason FBCrypto can do a
synchronous final flush of the in-memory counter buffer through
Scribe on process exit is that
folly::Singleton's lifecycle-management makes Scribe + its dependencies available in a well-defined order during shutdown. - Parallel note for Java: the 2024-12-02 post adds that "running something 'on shutdown' in Java requires using only synchronous I/O code and operating quickly" — identifying the general shutdown-environment constraint that applies to any language's telemetry-flush-on-exit path.
Seen in¶
- sources/2024-12-02-meta-built-large-scale-cryptographic-monitoring — cited by name as the primitive whose lifecycle semantics govern whether FBCrypto's shutdown-flush can reliably reach Scribe. A concrete example of how singleton-shutdown-order matters in a telemetry architecture with in-memory accumulation state.
Related¶
- systems/folly-concurrenthashmap — sibling folly primitive used for the buffer itself.
- systems/fbcrypto — the consumer whose shutdown-flush correctness depends on folly::Singleton.
- patterns/aggregating-buffered-logger — the telemetry architecture whose shutdown story folly::Singleton is part of.