folly::DigestBuilder

Stat digests, such as TDigest, can be expensive to merge. It is faster to buffer writes and merge them in larger chunks. DigestBuilder buffers writes to improve performance.

Synopsis

Declared in <folly/stats/DigestBuilder.h>

template<typename DigestT>
class DigestBuilder;

Description

Values are stored in a cpu local buffer. Hot stats will merge the cpu local buffer into a cpu-local digest when the buffer size is reached.

All methods in this class are thread safe, but it probably doesn't make sense for multiple threads to call build simultaneously. A typical usage is to buffer writes for a period of time, and then have one thread call build to merge the buffer into some other DigestT instance.

Member Functions

NameDescription
DigestBuilder [constructor]Constructs a builder with the given buffer and digest sizes.
append Adds a value to the buffer.
build Builds a DigestT from the buffer. All values used to build the DigestT are removed from the buffer.