`bool hdr_record_value(struct hdr_histogram* h, int64_t value)` can record out of bounds values and should be capped with min & max values

Open
#126 1 comment 1 reaction 1 assignee View on GitHub

@filipecosta90 is already working on this.

Since Nov 12, 2024.

Assessment

This issue has not been assessed yet.

Description

bug

RedisInc's memtier_benchmark suffered from some issues where very-large or very-small values were being written to the histogram and either causing nan/inf output or incorrect output in the benchmarking metrics.

A workaround was introduced in this PR: https://github.com/RedisLabs/memtier_benchmark/pull/273

They introduced a (spiritual) overload, hdr_record_value_capped(), with impl:

// hdr_histogram.c
bool hdr_record_value_capped(struct hdr_histogram* h, int64_t value)
{
    int64_t capped_value = (value > h->highest_trackable_value) ? h->highest_trackable_value : value;
    capped_value = (capped_value < h->lowest_trackable_value) ? h->lowest_trackable_value : capped_value;
    return hdr_record_value(h, capped_value);
}

But it seems as if this change should be made directly to this library. Either in a similar way, or by returning an error to the caller. OR, at the very least, this strange behavior/limitation called out in the method docs for hdr_record_value(). E.g. "This method does not properly handle values that are outside the trackable range of the histogram. Please very inputs before calling."

@filipecosta90

Dominant language
C
Stars
290
Forks
111
Avg merge
1d 16h
Merged PRs (30d)
3

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HdrHistogram/HdrHistogram_c

All issues in HdrHistogram/HdrHistogram_c

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.