{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/17757","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/17757/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/17757/comments","events_url":"https://api.github.com/repos/golang/go/issues/17757/events","html_url":"https://github.com/golang/go/issues/17757","id":186962864,"number":17757,"title":"time: Tick docs don't mention CPU cost of \"leaks\"","user":{"login":"manishrjain","id":1782324,"avatar_url":"https://avatars.githubusercontent.com/u/1782324?v=3","gravatar_id":"","url":"https://api.github.com/users/manishrjain","html_url":"https://github.com/manishrjain","followers_url":"https://api.github.com/users/manishrjain/followers","following_url":"https://api.github.com/users/manishrjain/following{/other_user}","gists_url":"https://api.github.com/users/manishrjain/gists{/gist_id}","starred_url":"https://api.github.com/users/manishrjain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manishrjain/subscriptions","organizations_url":"https://api.github.com/users/manishrjain/orgs","repos_url":"https://api.github.com/users/manishrjain/repos","events_url":"https://api.github.com/users/manishrjain/events{/privacy}","received_events_url":"https://api.github.com/users/manishrjain/received_events","type":"User","site_admin":false},"labels":[{"id":150880209,"url":"https://api.github.com/repos/golang/go/labels/Documentation","name":"Documentation","color":"aaffaa","default":false},{"id":373399998,"url":"https://api.github.com/repos/golang/go/labels/NeedsFix","name":"NeedsFix","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/42","html_url":"https://github.com/golang/go/milestones/Go1.8Maybe","labels_url":"https://api.github.com/repos/golang/go/milestones/42/labels","id":1748849,"number":42,"title":"Go1.8Maybe","description":"","creator":{"login":"bradfitz","id":2621,"avatar_url":"https://avatars.githubusercontent.com/u/2621?v=3","gravatar_id":"","url":"https://api.github.com/users/bradfitz","html_url":"https://github.com/bradfitz","followers_url":"https://api.github.com/users/bradfitz/followers","following_url":"https://api.github.com/users/bradfitz/following{/other_user}","gists_url":"https://api.github.com/users/bradfitz/gists{/gist_id}","starred_url":"https://api.github.com/users/bradfitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradfitz/subscriptions","organizations_url":"https://api.github.com/users/bradfitz/orgs","repos_url":"https://api.github.com/users/bradfitz/repos","events_url":"https://api.github.com/users/bradfitz/events{/privacy}","received_events_url":"https://api.github.com/users/bradfitz/received_events","type":"User","site_admin":false},"open_issues":52,"closed_issues":143,"state":"open","created_at":"2016-05-04T23:40:26Z","updated_at":"2016-11-04T05:55:14Z","due_on":"2017-01-31T00:00:00Z","closed_at":null},"comments":1,"created_at":"2016-11-03T01:44:35Z","updated_at":"2016-11-04T12:00:59Z","closed_at":null,"body":"Please answer these questions before submitting your issue. Thanks!\r\n\r\n### What version of Go are you using (`go version`)?\r\n1.7.3\r\n\r\n### What operating system and processor architecture are you using (`go env`)?\r\namd64, Arch Linux\r\n\r\n### What did you do?\r\nIf possible, provide a recipe for reproducing the error.\r\nA complete runnable program is good.\r\nA link on play.golang.org is best.\r\n\r\nRead the documentation here: https://golang.org/pkg/time/#Tick\r\nAnd 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.\r\n\r\nI ran into this problem, more details here:\r\nhttps://forum.golangbridge.org/t/runtime-siftdowntimer-consuming-60-of-the-cpu/3773\r\n\r\nA 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\r\n\r\n\r\n### What did you expect to see?\r\nThe 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.\r\n\r\nSuch 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.\r\n\r\nThought: Long term, IMO, this function should be discontinued, but that's just a thought, and it's not what I'm proposing here.\r\n\r\n### What did you see instead?\r\nThe 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.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/258413915","html_url":"https://github.com/golang/go/issues/17757#issuecomment-258413915","issue_url":"https://api.github.com/repos/golang/go/issues/17757","id":258413915,"user":{"login":"manishrjain","id":1782324,"avatar_url":"https://avatars.githubusercontent.com/u/1782324?v=3","gravatar_id":"","url":"https://api.github.com/users/manishrjain","html_url":"https://github.com/manishrjain","followers_url":"https://api.github.com/users/manishrjain/followers","following_url":"https://api.github.com/users/manishrjain/following{/other_user}","gists_url":"https://api.github.com/users/manishrjain/gists{/gist_id}","starred_url":"https://api.github.com/users/manishrjain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manishrjain/subscriptions","organizations_url":"https://api.github.com/users/manishrjain/orgs","repos_url":"https://api.github.com/users/manishrjain/repos","events_url":"https://api.github.com/users/manishrjain/events{/privacy}","received_events_url":"https://api.github.com/users/manishrjain/received_events","type":"User","site_admin":false},"created_at":"2016-11-04T12:00:59Z","updated_at":"2016-11-04T12:00:59Z","body":"Hey @iand,\r\n\r\nWhile you're technically right that \"leak\" could mean any resource, that's not the popular definition of leaks. Doing a Google search for [memory leak] shows 4.2M results. Doing a google search for [resource leak] and [cpu leak] show 370K and 660K results, respectively -- tiny in comparison to the former. Most developers would read these lines and come out thinking the doc is purely about memory leak. Anecdotal evidence:\r\n\r\nhttps://twitter.com/KarlKFI/status/793643218336227329\r\nhttps://twitter.com/vCabbage/status/793651308360179712\r\n\r\nAnd memory leak makes sense. It's a common problem with C++ programs, and when GC can't reach something, memory leaking is already expected and quickly assumed. Typically, these leaking structures are passive, and they just lie around consuming only memory; but timer is not a passive structure.\r\n\r\nAnd therein lies the confusion. I think we should trade clarity over a technicality, and outright mention the more significant adverse effect, which is CPU consumption caused by a fast iterating loop using this wrapper function."}}
{"actor":{"display_login":"manishrjain"}}