folly::compression::CompressionCoreLocalContextPool

This class is intended to reduce contention on reserving a compression context and improve cache locality (but maybe not hotness) of the contexts it manages.

Synopsis

Declared in <folly/compression/CompressionCoreLocalContextPool.h>

template<
    typename T,
    typename Creator,
    typename Deleter,
    typename Resetter,
    typename Sizeof,
    typename Callback = CompressionContextPoolDefaultCallback>
class CompressionCoreLocalContextPool
    : public CompressionCoreLocalContextPoolBase

Description

This class uses folly::AccessSpreader to spread the managed object across NumStripes domains (which should correspond to a topologically close set of hardware threads). This cache is still backed by the basic locked stack in the folly::compression::CompressionContextPool.

Note that there is a tradeoff in choosing the number of stripes. More stripes make for less contention, but mean that a context is less likely to be hot in cache.

Base Classes

NameDescription
CompressionCoreLocalContextPoolBaseNon-templated base class which allows for generic interaction with context pool instances.

Type Aliases

NameDescription
Object The pooled object type.
Ref Owning handle to a pooled object that returns it to the pool on destruction.

Member Functions

NameDescription
CompressionCoreLocalContextPool [constructor]Constructs a core-local pool with the given stripe count and functors.
~CompressionCoreLocalContextPool [destructor] [virtual]Destroys the pool, returning cached contexts to the backing pool.
bytes_used Returns the total bytes of memory used by cached and backing contexts.
cacheSize Returns the current number of stripes.
created_count Returns the number of contexts ever created by the backing pool.
flush_deep Releases cached contexts and the backing pool's contexts.
flush_shallow Returns all core-local cached contexts to the backing pool.
get Checks out a context, creating one via the backing pool if needed.
getNull Returns an empty handle bound to this pool.
setSize [virtual]Update the number of stripes. This will flush the pool if the stripe count changes.

Static Data Members

NameDescription
kMaxNumStripes The max size is derived from maximum stripes for folly::AccessSpreader.