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

timer count sampling and persist #93

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ploxiln
Copy link
Contributor

@ploxiln ploxiln commented Jul 27, 2018

This started with the motivation of making timer ".count" keys persist like counters, and also it seems like they're intended to honor the sampling so they should do that too. But the next annoying bit is how postfix needs to be removed and re-added for timers, so maybe postfix should be added last ... but then receive-counter should probably keep its current behavior of not getting the prefix/postfix ... and then when trying to add code concisely it becomes apparent that much of packetHandler() can just be removed ...

It's best to look at each commit individually for a good explanation. I would also be willing to break out some separate pull-requests (and then this one would depend on most of those going in first).

According to our benchmarks, handling timers got a bit slower, because now it adds to two maps instead of one. Some other stuff got a bit better. EDIT: refactored, and updated benchmark results.

benchmark                         old ns/op      new ns/op      delta
BenchmarkManyDifferentSensors     1340102699     1366014386     +1.93%
BenchmarkOneBigTimer              1247196564     1250918558     +0.30%
BenchmarkLotsOfTimers             1340196338     1371868042     +2.36%
BenchmarkMsgParserUDP             1224           1217           -0.57%
BenchmarkMsgParserTCP             1101           1097           -0.36%
BenchmarkParseLineCounter         888            871            -1.91%
BenchmarkParseLineGauge           881            836            -5.11%
BenchmarkParseLineTimer           853            834            -2.23%
BenchmarkParseLineSet             777            769            -1.03%
BenchmarkPacketHandlerCounter     79.9           72.0           -9.89%
BenchmarkPacketHandlerGauge       71.3           73.1           +2.52%
BenchmarkPacketHandlerTimer       126            97.3           -22.78%
BenchmarkPacketHandlerSet         123            102            -17.07%

benchmark                         old allocs     new allocs     delta
BenchmarkManyDifferentSensors     35058          38064          +8.57%
BenchmarkOneBigTimer              33             36             +9.09%
BenchmarkLotsOfTimers             25017          28017          +11.99%
BenchmarkMsgParserUDP             15             15             +0.00%
BenchmarkMsgParserTCP             14             14             +0.00%
BenchmarkParseLineCounter         13             13             +0.00%
BenchmarkParseLineGauge           13             13             +0.00%
BenchmarkParseLineTimer           12             12             +0.00%
BenchmarkParseLineSet             12             12             +0.00%
BenchmarkPacketHandlerCounter     0              0              +0.00%
BenchmarkPacketHandlerGauge       0              0              +0.00%
BenchmarkPacketHandlerTimer       0              0              +0.00%
BenchmarkPacketHandlerSet         0              0              +0.00%

benchmark                         old bytes     new bytes     delta
BenchmarkManyDifferentSensors     1556072       1664552       +6.97%
BenchmarkOneBigTimer              1400          1512          +8.00%
BenchmarkLotsOfTimers             839976        930824        +10.82%
BenchmarkMsgParserUDP             596           596           +0.00%
BenchmarkMsgParserTCP             549           549           +0.00%
BenchmarkParseLineCounter         440           440           +0.00%
BenchmarkParseLineGauge           432           432           +0.00%
BenchmarkParseLineTimer           464           464           +0.00%
BenchmarkParseLineSet             460           460           +0.00%
BenchmarkPacketHandlerCounter     0             0             +0.00%
BenchmarkPacketHandlerGauge       0             0             +0.00%
BenchmarkPacketHandlerTimer       80            80            +0.00%
BenchmarkPacketHandlerSet         65            65            +0.00%

@ploxiln ploxiln force-pushed the timer_counter_fix branch 2 times, most recently from 029cd0e to d9e86f9 Compare July 27, 2018 22:38
@ploxiln
Copy link
Contributor Author

ploxiln commented Jul 27, 2018

squashed in two little cleanup commits

@ploxiln
Copy link
Contributor Author

ploxiln commented Jul 31, 2018

I'm actually going to do more work on this ...

works out great: adding to zero works,
and a "nil" slice, which acts like an empty slice, works with append()
Gauge relative change limit checks are a hold-over from when
gauge values were uint64.

float64 loses much precision at very high values, and it rounds to
values it is able to represent: MaxFloat64 + 123456789.0 = MaxFloat64
(you have to subtract about 1e292 to get it to budge!)

Negative gauge results seem to be part of the informal spec:
> This implies you can't explicitly set a gauge to a negative number
> without first setting it to zero.
https://github.com/etsy/statsd/blob/master/docs/metric_types.md#gauges

And really, who uses relative gauge changes anyway ...
instead of just after parsing bucket/key before counting
 - less work if multiple messages aggregate into single bucket

need special handling for receive-counter so it continues to
not have prefix/postfix apply to it

rename countInactivity to inactivCounters, change to map[string]uint
(planning to add inactivTimers etc)

update tests for prefix/postfix applied during different stage

and minor cleanup to TestProcessCounters persist-count-keys bits
by putting the sampled count first in the time values array
and with new inactivTimers map

also, BenchmarkManyDifferentSensors should clear the stats maps ...
@ploxiln
Copy link
Contributor Author

ploxiln commented Jul 31, 2018

refactored a bit, updated benchmark results

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

Successfully merging this pull request may close these issues.

1 participant