Skip to content

Commit

Permalink
Bump medida for #2518 (metrics overflow) and add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
graydon committed Jun 16, 2020
1 parent cebd7fd commit 452444f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/libmedida
21 changes: 21 additions & 0 deletions src/util/test/MetricTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,3 +502,24 @@ TEST_CASE("sliding window percentiles - alternating frequencies and patterns",
swt.addUniformSamplesAtHighFrequency(1, 100);
swt.checkPercentiles(false);
}

TEST_CASE("sums of nanoseconds do not overflow", "[medida_math]")
{
// This tests that sums (and possibly other derived values of accumulated
// nanoseconds -- billionths of a second) in medida are not stored in an
// int64 and therefore don't overflow after a few months of accumulation at
// decently-high frequency.
medida::Histogram hist;
int64_t billion = 1000000000;
int64_t billion_billion = billion * billion;
// the biggest int64_t is 9.2 billion billion.
for (size_t i = 0; i < 15; ++i)
{
hist.Update(billion_billion);
REQUIRE(hist.sum() >= 0);
REQUIRE(hist.min() >= 0);
REQUIRE(hist.max() >= 0);
REQUIRE(hist.mean() >= 0);
REQUIRE(hist.std_dev() >= 0);
}
}

5 comments on commit 452444f

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from MonsieurNicolas
at graydon@452444f

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging graydon/stellar-core/bug-2518-negative-metrics = 452444f into auto

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

graydon/stellar-core/bug-2518-negative-metrics = 452444f merged ok, testing candidate = 4e953fa

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 4e953fa

Please sign in to comment.