time: Tick docs don't mention CPU cost of "leaks" #17757
Labels
Documentation
Issues describing a change to documentation.
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?1.7.3
What operating system and processor architecture are you using (
go env
)?amd64, Arch Linux
What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
Read the documentation here: https://golang.org/pkg/time/#Tick
And comprehend what it says, before reading any further. If you do, you would come out understanding the memory cost of this wrapper function. But, most likely, you won't come out understanding the CPU cost.
I ran into this problem, more details here:
https://forum.golangbridge.org/t/runtime-siftdowntimer-consuming-60-of-the-cpu/3773
A simple code snippet which would show the memory and CPU cost of this wrapper function. CPU cost is significantly more noticeable than memory cost: https://play.golang.org/p/vi9D0oZqOQ
What did you expect to see?
The documentation should clearly mention that the "leaks" could significantly affect your CPU usage, even more so than memory, because the "zombie" tickers (created by each iteration) are still doing work.
Such a notice would very actively discourage a nonchalant usage of this wrapper function. Memory leak is bad, but it's not nearly as noticeable in this case, as tickers actively hitting your CPU, doing an equivalent of a busy-wait.
Thought: Long term, IMO, this function should be discontinued, but that's just a thought, and it's not what I'm proposing here.
What did you see instead?
The convenience wrapper talks about "leaks," which typically engineers understand as memory leaks. However, memory leaks are insignificant compared to the CPU cost of running
time.Tick
in a fast iterating loop.The text was updated successfully, but these errors were encountered: