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

memmetrics: Optimize RollingCounter Inc and Count operations #167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AlexisMontagne
Copy link

The overall performance of the counter has been improved, there is a little performance regression in a corner case (large bucket with contiguous values)

Find attached some benchmark results of this modification:

benchmark                                      old ns/op     new ns/op     delta
BenchmarkCounterIncOnly/size-3-4               203           53.4          -73.69%
BenchmarkCounterIncOnly/size-5-4               192           52.3          -72.76%
BenchmarkCounterIncOnly/size-10-4              198           59.0          -70.20%
BenchmarkCounterIncOnly/size-20-4              199           62.4          -68.64%
BenchmarkCounterIncOnly/size-50-4              196           58.5          -70.15%
BenchmarkCounterIncOnly/size-100-4             189           57.5          -69.58%
BenchmarkCounterIncCountContigu/size-3-4       249           111           -55.42%
BenchmarkCounterIncCountContigu/size-5-4       249           125           -49.80%
BenchmarkCounterIncCountContigu/size-10-4      262           180           -31.30%
BenchmarkCounterIncCountContigu/size-20-4      257           285           +10.89%
BenchmarkCounterIncCountContigu/size-50-4      270           610           +125.93%
BenchmarkCounterIncCountContigu/size-100-4     295           1054          +257.29%
BenchmarkCounterIncCountSparse/size-3-4        379           104           -72.56%
BenchmarkCounterIncCountSparse/size-5-4        485           95.9          -80.23%
BenchmarkCounterIncCountSparse/size-10-4       482           102           -78.84%
BenchmarkCounterIncCountSparse/size-20-4       478           168           -64.85%
BenchmarkCounterIncCountSparse/size-50-4       488           181           -62.91%
BenchmarkCounterIncCountSparse/size-100-4      494           298           -39.68%

FYI: The struct is now really thread safe.

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

Successfully merging this pull request may close these issues.

None yet

1 participant