Do I need to reset the counters?

96 views
Skip to first unread message

Gabriel Popescu

unread,
Feb 23, 2015, 1:37:32 AM2/23/15
to metric...@googlegroups.com
Hi,

I have an application that uses meters and histograms. Both of them have a 'Count' attribute. They get incremented about a million times per day. Should I worry about overflow? Or is there any metrics feature (I can't imagine one though) to prevent overflowing?

Thanks,
Gabriel

Ryan Tenney

unread,
Feb 23, 2015, 10:08:21 AM2/23/15
to metric...@googlegroups.com
Hi Gabriel,

You needn't worry about counters overflowing, as the count on each of the metrics is a long, which has a max value of 2^63 - 1.  You'd be able to increment one by 1 million every day for just over 25 billion years before an overflow occurs (which Wolfram Alpha helpfully tells us is ~2.5 × the expected lifetime of the sun).  There are frequent requests for the ability to perform resets on metrics, but that is a surprisingly difficult feature to implement correctly without adding additional synchronization on every call to the metrics.

Cheers,
Ryan

Gabriel Popescu

unread,
Feb 25, 2015, 8:46:54 AM2/25/15
to metric...@googlegroups.com
Hi Ryan,

Thank you for your answer.
We are now worried about another thing.
In histograms, in JConsole I see an operation called: long[] values. Does this mean that, in order for the library to do the math, it stores all the values (so, a number of 'Count' values)? Because, if we have billions of values stored, we might have memory issues. Or maybe it relies on some more complex mathematical formula?

Regards,
Gabriel

Jens

unread,
Feb 25, 2015, 10:20:02 AM2/25/15
to metric...@googlegroups.com

In histograms, in JConsole I see an operation called: long[] values. Does this mean that, in order for the library to do the math, it stores all the values (so, a number of 'Count' values)? Because, if we have billions of values stored, we might have memory issues. Or maybe it relies on some more complex mathematical formula?

Histograms store a representative set of values to calculate the distribution of values. In [1] it is stated that a full biased histogram requires ~87 kb memory. So every 10 histograms using the default ExponentiallyDecayingReservoir require ~1MB memory. 


-- J.

Ryan Rupp

unread,
Feb 25, 2015, 7:40:07 PM2/25/15
to metric...@googlegroups.com
I'll also note that since I posted that Metrics 3.0 came out (or maybe it was out then, but I wasn't using it yet) which allows you to tweak the reservoir type and size although things like changing the size would potentially affect the statistical accuracy of the distribution. Also different reservoirs have different performance characteristics (the github repo has JMH benchmarks for them).
Reply all
Reply to author
Forward
0 new messages