Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #126

Open
DrEsteban opened this issue Nov 11, 2024 · 1 comment
Assignees
Labels

Comments

@DrEsteban
Copy link

DrEsteban commented Nov 11, 2024

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: RedisLabs/memtier_benchmark#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

@mikeb01
Copy link
Contributor

mikeb01 commented Nov 14, 2024

I've added checking for the upper bound. I've found a couple of issues with checking the lower bound, which I will need to look into more detail and compare the Java implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants