Skip to content

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::Singleton for 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

Last updated · 319 distilled / 1,201 read