Loading...
Searching...
No Matches
histogram_data.h File Reference

Generic histogram library. More...

Data Structures

struct  spdk_histogram_data
 
struct  spdk_histogram_borders
 

Macros

#define SPDK_HISTOGRAM_GRANULARITY_DEFAULT   7
 
#define SPDK_HISTOGRAM_GRANULARITY(h)   h->granularity
 
#define SPDK_HISTOGRAM_BUCKET_LSB(h)   (64 - SPDK_HISTOGRAM_GRANULARITY(h))
 
#define SPDK_HISTOGRAM_NUM_BUCKETS_PER_RANGE(h)   (1ULL << SPDK_HISTOGRAM_GRANULARITY(h))
 
#define SPDK_HISTOGRAM_BUCKET_MASK(h)   (SPDK_HISTOGRAM_NUM_BUCKETS_PER_RANGE(h) - 1)
 
#define SPDK_HISTOGRAM_NUM_BUCKET_RANGES(h)   (h->max_range - h->min_range + 1)
 
#define SPDK_HISTOGRAM_NUM_BUCKETS(h)
 

Typedefs

typedef void(* spdk_histogram_data_fn) (void *ctx, uint64_t start, uint64_t end, uint64_t count, uint64_t total, uint64_t so_far)
 

Functions

static void __spdk_histogram_increment (struct spdk_histogram_data *h, uint32_t range, uint32_t index)
 
static uint64_t __spdk_histogram_get_count (const struct spdk_histogram_data *h, uint32_t range, uint32_t index)
 
static uint64_t * __spdk_histogram_get_bucket (const struct spdk_histogram_data *h, uint32_t range, uint32_t index)
 
static void spdk_histogram_data_reset (struct spdk_histogram_data *histogram)
 
static uint32_t __spdk_histogram_data_get_bucket_range (struct spdk_histogram_data *h, uint64_t datapoint)
 
static uint32_t __spdk_histogram_data_get_bucket_index (struct spdk_histogram_data *h, uint64_t datapoint, uint32_t range)
 
static void spdk_histogram_data_tally (struct spdk_histogram_data *histogram, uint64_t datapoint)
 
static uint64_t __spdk_histogram_data_get_bucket_start (const struct spdk_histogram_data *h, uint32_t range, uint32_t index)
 
static void spdk_histogram_data_iterate (const struct spdk_histogram_data *histogram, spdk_histogram_data_fn fn, void *ctx)
 
static int spdk_histogram_data_merge (const struct spdk_histogram_data *dst, const struct spdk_histogram_data *src)
 
static struct spdk_histogram_dataspdk_histogram_data_alloc_sized_ext (uint32_t granularity, uint64_t min_val, uint64_t max_val)
 Allocate a histogram data structure with specified granularity.
 
static struct spdk_histogram_dataspdk_histogram_data_alloc_sized (uint32_t granularity)
 
static struct spdk_histogram_dataspdk_histogram_data_alloc (void)
 
static void spdk_histogram_data_free (struct spdk_histogram_data *h)
 
static void __spdk_histogram_get_borders_count_cb (void *_ctx, uint64_t start, uint64_t end, uint64_t count, uint64_t total, uint64_t so_far)
 
static void spdk_histogram_get_borders_count (struct spdk_histogram_data *h, struct spdk_histogram_borders *ctx)
 Dump histogram buckets for specified borders.
 
static struct spdk_histogram_bordersspdk_histogram_get_borders_count_alloc_ctx (uint64_t *borders, size_t num_borders)
 Allocate a context to dump histogram buckets for specified borders.
 
static void spdk_histogram_get_borders_count_free_ctx (struct spdk_histogram_borders *ctx)
 Free the context allocated by spdk_histogram_get_borders_count_alloc_ctx().
 

Detailed Description

Generic histogram library.

Macro Definition Documentation

◆ SPDK_HISTOGRAM_NUM_BUCKETS

#define SPDK_HISTOGRAM_NUM_BUCKETS ( h)
Value:
(SPDK_HISTOGRAM_NUM_BUCKETS_PER_RANGE(h) * \
SPDK_HISTOGRAM_NUM_BUCKET_RANGES(h))

Function Documentation

◆ spdk_histogram_data_alloc_sized_ext()

static struct spdk_histogram_data * spdk_histogram_data_alloc_sized_ext ( uint32_t granularity,
uint64_t min_val,
uint64_t max_val )
inlinestatic

Allocate a histogram data structure with specified granularity.

It tracks datapoints from min_val (inclusive) to max_val (exclusive).

Parameters
granularityGranularity of the histogram buckets. Each power-of-2 range is split into (1 << granularity) buckets.
min_valThe minimum value to be tracked, inclusive.
max_valThe maximum value to be tracked, exclusive.
Returns
A histogram data structure.

◆ spdk_histogram_get_borders_count()

static void spdk_histogram_get_borders_count ( struct spdk_histogram_data * h,
struct spdk_histogram_borders * ctx )
inlinestatic

Dump histogram buckets for specified borders.

Parameters
hThe histogram data to dump.
ctxThe context to dump histogram buckets for specified borders, allocated by spdk_histogram_get_borders_count_alloc_ctx().

◆ spdk_histogram_get_borders_count_alloc_ctx()

static struct spdk_histogram_borders * spdk_histogram_get_borders_count_alloc_ctx ( uint64_t * borders,
size_t num_borders )
inlinestatic

Allocate a context to dump histogram buckets for specified borders.

The borders array must be sorted in ascending order, each border represents a value which is an upper bound of a bucket. border_count will contain the count of all values that are less or equal to its border value. Reported border_count will contain one more element than the borders array, the last element will represent total count of all elements in the histogram.

Parameters
bordersAn array of border values, must be sorted in ascending order.
num_bordersThe number of borders in the borders array.
Returns
A context to dump histogram buckets for specified borders.

+1 for bucket containing values from last border to +Inf

◆ spdk_histogram_get_borders_count_free_ctx()

static void spdk_histogram_get_borders_count_free_ctx ( struct spdk_histogram_borders * ctx)
inlinestatic

Free the context allocated by spdk_histogram_get_borders_count_alloc_ctx().

Parameters
ctxThe context to free.