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

Cannot read LongHistogram back from histogram log when recorded value count exceeds ~10000 #99

Open
scharnyw opened this issue Aug 26, 2024 · 1 comment

Comments

@scharnyw
Copy link

Run the following code to reproduce.

var histogram = new LongHistogram(TimeSpan.FromMinutes(40).Ticks, 4);
var maxValue = TimeSpan.FromMinutes(20).Ticks;

var count = 10000;
for (var i = 0; i < count; i++)
{
    histogram.RecordValue(Random.Shared.NextInt64(maxValue));
}

await using var ms = new MemoryStream();
HistogramLogWriter.Write(ms, DateTimeOffset.FromUnixTimeMilliseconds(histogram.StartTimeStamp).UtcDateTime, histogram);

ms.Position = 0;

var readBackHistograms = new HistogramLogReader(ms).ReadHistograms().ToList();

When count is 10000 or more, the last line consistently throws the following exception:

System.ArgumentException: 'The buffer does not contain the indicated payload amount'

But when count is set to 9000, it runs successfully without issue.

I'm using HdrHistogram v2.5.0 on .NET 8.

@LeeCampbell
Copy link
Collaborator

Thanks for raising. I have a unit test reproducing the error.
Will target this issue in the PR fix

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

No branches or pull requests

2 participants