Home | History | Annotate | Download | only in isc

Lines Matching refs:hg

57 #define DENORMALS(hg) ((hg)->sigbits - 1)
58 #define MANTISSAS(hg) (1 << (hg)->sigbits)
59 #define EXPONENTS(hg) (CHUNKS - DENORMALS(hg))
60 #define BUCKETS(hg) (EXPONENTS(hg) * MANTISSAS(hg))
62 #define MAXCHUNK(hg) EXPONENTS(hg)
63 #define CHUNKSIZE(hg) MANTISSAS(hg)
82 isc_histo_t *hg[];
94 isc_histo_t *hg = isc_mem_get(mctx, sizeof(*hg));
95 *hg = (isc_histo_t){
99 isc_mem_attach(mctx, &hg->mctx);
101 *hgp = hg;
109 isc_histo_t *hg = *hgp;
113 if (hg->chunk[c] != NULL) {
114 isc_mem_cput(hg->mctx, hg->chunk[c], CHUNKSIZE(hg),
118 isc_mem_putanddetach(&hg->mctx, hg, sizeof(*hg));
124 isc_histo_sigbits(isc_histo_t *hg) {
125 REQUIRE(HISTO_VALID(hg));
126 return hg->sigbits;
186 value_to_key(const isc_histo_t *hg, uint64_t value) {
188 uint64_t chunked = value | CHUNKSIZE(hg);
191 uint exponent = 63 - hg->sigbits - clz;
195 return (exponent << hg->sigbits) + mantissa;
210 * The largest key passed by `key_to_maxval()` is `BUCKETS(hg)`, so
211 * `exponent == EXPONENTS(hg) - 1 == 64 - sigbits`
220 key_to_minval(const isc_histo_t *hg, uint key) {
221 uint chunksize = CHUNKSIZE(hg);
228 key_to_maxval(const isc_histo_t *hg, uint key) {
229 return key_to_minval(hg, key + 1) - 1;
235 key_to_new_bucket(isc_histo_t *hg, uint key) {
237 uint chunksize = CHUNKSIZE(hg);
241 hg_bucket_t *new_cp = isc_mem_cget(hg->mctx, CHUNKSIZE(hg),
243 hg_chunk_t *cpp = &hg->chunk[chunk];
248 isc_mem_cput(hg->mctx, new_cp, CHUNKSIZE(hg),
255 get_chunk(const isc_histo_t *hg, uint chunk) {
256 return atomic_load_acquire(&hg->chunk[chunk]);
260 key_to_bucket(const isc_histo_t *hg, uint key) {
262 uint chunksize = CHUNKSIZE(hg);
265 hg_bucket_t *cp = get_chunk(hg, chunk);
275 get_key_count(const isc_histo_t *hg, uint key) {
276 return bucket_count(key_to_bucket(hg, key));
280 add_key_count(isc_histo_t *hg, uint key, uint64_t inc) {
283 hg_bucket_t *bp = key_to_bucket(hg, key);
284 bp = bp != NULL ? bp : key_to_new_bucket(hg, key);
292 isc_histo_add(isc_histo_t *hg, uint64_t value, uint64_t inc) {
293 REQUIRE(HISTO_VALID(hg));
294 add_key_count(hg, value_to_key(hg, value), inc);
298 isc_histo_inc(isc_histo_t *hg, uint64_t value) {
299 isc_histo_add(hg, value, 1);
303 isc_histo_put(isc_histo_t *hg, uint64_t min, uint64_t max, uint64_t count) {
304 REQUIRE(HISTO_VALID(hg));
306 uint kmin = value_to_key(hg, min);
307 uint kmax = value_to_key(hg, max);
310 uint64_t mid = ISC_MIN(max, key_to_maxval(hg, key));
314 add_key_count(hg, key, inc);
321 isc_histo_get(const isc_histo_t *hg, uint key, uint64_t *minp, uint64_t *maxp,
323 REQUIRE(HISTO_VALID(hg));
325 if (key < BUCKETS(hg)) {
326 SET_IF_NOT_NULL(minp, key_to_minval(hg, key));
327 SET_IF_NOT_NULL(maxp, key_to_maxval(hg, key));
328 SET_IF_NOT_NULL(countp, get_key_count(hg, key));
336 isc_histo_next(const isc_histo_t *hg, uint *keyp) {
337 REQUIRE(HISTO_VALID(hg));
340 uint chunksize = CHUNKSIZE(hg);
341 uint buckets = BUCKETS(hg);
346 key_to_bucket(hg, key) == NULL)
384 STRUCT_FLEX_SIZE(hm, hg, size));
391 isc_histo_create(mctx, sigbits, &hm->hg[i]);
403 isc_mem_t *mctx = hm->hg[0]->mctx;
407 isc_histo_destroy(&hm->hg[i]);
410 isc_mem_put(mctx, hm, STRUCT_FLEX_SIZE(hm, hg, hm->size));
418 isc_histo_merge(hgp, hm->hg[i]);
425 isc_histo_t *hg = hm->hg[isc_tid()];
426 add_key_count(hg, value_to_key(hg, value), inc);
441 isc_histo_moments(const isc_histo_t *hg, double *pm0, double *pm1,
443 REQUIRE(HISTO_VALID(hg));
451 isc_histo_get(hg, key, &min, &max, &count) == ISC_R_SUCCESS;
452 isc_histo_next(hg, &key))
494 isc_histo_quantiles(const isc_histo_t *hg, uint size, const double *fraction,
500 REQUIRE(HISTO_VALID(hg));
505 const uint maxchunk = MAXCHUNK(hg);
506 const uint chunksize = CHUNKSIZE(hg);
516 chunk[c] = get_chunk(hg, c);
564 value[i] = lerp(key_to_minval(hg, key),
565 key_to_maxval(hg, key),