An allocator that can be used with AccessSpreader to allocate core‐local memory.

Synopsis

Declared in <folly/concurrency/CacheLocality.h>

void*
coreMalloc(
    size_t size,
    size_t numStripes,
    size_t stripe);

Description

There is actually nothing special about the memory itself (it is not bound to NUMA nodes or anything), but the allocator guarantees that memory allocatd from the same stripe will only come from cache lines also allocated to the same stripe, for the given numStripes. This means multiple things using AccessSpreader can allocate memory in smaller‐than cacheline increments, and be assured that it won't cause more false sharing than it otherwise would.

Allocations smaller than sizeof(void*) (typically 8 bytes) are automatically rounded up to ensure correct internal bookkeeping.

Note that allocation and deallocation takes a per‐size‐class lock.

Memory allocated with coreMalloc() must be freed with coreFree().

Return Value

A pointer to the allocated core‐local memory.

Parameters

Name

Description

size

Number of bytes to allocate.

numStripes

Total number of stripes the allocation is spread across.

stripe

Stripe the allocation is bound to, less than numStripes.

Created with MrDocs