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

Derivative of a constant counter is _close_ to zero, instead of zero #4373

Closed
maurorappa opened this Issue Jul 12, 2018 · 6 comments

Comments

Projects
None yet
2 participants
@maurorappa
Copy link

maurorappa commented Jul 12, 2018

What did you do?
I have a simple constant counter:
counter

I want its derivative, being a constant it should be zero, but it looks like some calculation is done and rounding is appening.
deriv-counter

What did you expect to see?

By definition, its derivative should be zero

What did you see instead? Under which circumstances?

a value close to zero, which of course could be rounded to it :)
Being a special case (constant value) is could return zero immediately without calculations (performance saving)

  • System information:

Linux 3.10.0-693.11.6.el7.x86_64 x86_64insert output of uname -srm here

  • Prometheus version:

prometheus, version 2.3.0 (branch: HEAD, revision: 290d717)
build user: root@d539e167976a
build date: 20180607-08:46:54
go version: go1.10.2

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jul 12, 2018

This smells like floating point inaccuracy, which there are limited options for dealing with as it'd likely just pop up in another form. I'm not sure we should special case, do you have a proposed tweak to the order of operations?

@maurorappa

This comment has been minimized.

Copy link
Author

maurorappa commented Jul 12, 2018

I understand we don't want to complicate the code for edge cases, one approach could be using the function 'funcChanges' in 'funcDeriv' before calling 'linearRegression'.
Of course it needs to be benchmarked to see any saving (time,cpu), I could give a go if you think it's useful.

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jul 12, 2018

I'd classify that as special casing. I'm not sure there's much we can sanely do here.

@maurorappa

This comment has been minimized.

Copy link
Author

maurorappa commented Jul 12, 2018

your call ;)
feel free to close it

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jul 12, 2018

I don't see anything obvious we can do.

Also, that's a counter. You should only use deriv on gauges. You want rate.

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 22, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 22, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.