{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes/heapster/pulls/comments/36890698","id":36890698,"diff_hunk":"@@ -0,0 +1,442 @@\n+// Copyright 2015 Google Inc. All Rights Reserved.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+package store\n+\n+import (\n+\t\"container/list\"\n+\t\"fmt\"\n+\t\"math\"\n+\t\"sort\"\n+\t\"sync\"\n+\t\"time\"\n+)\n+\n+func NewStatStore(epsilon uint64, resolution time.Duration, windowDuration uint8, supportedPercentiles []float64) *statStore {\n+\treturn &statStore{\n+\t\tbuffer:               list.New(),\n+\t\tepsilon:              epsilon,\n+\t\tresolution:           resolution,\n+\t\twindowDuration:       windowDuration,\n+\t\tsupportedPercentiles: supportedPercentiles,\n+\t}\n+}\n+\n+// statStore is an in-memory rolling timeseries buffer that allows the extraction of -\n+// segments of the stored timeseries and derived stats.\n+// The tradeoff between space and precision can be configured through epsilon and resolution.\n+// statStore only retains information about the latest TimePoints that are within its\n+// specified duration.\n+// statStore is a TimeStore-like object that does not implement the TimeStore interface.\n+type statStore struct {\n+\t// start is the start of the time window.\n+\tstart time.Time\n+\n+\t// buffer is a list of tpBucket that is sequenced in a time-descending order, meaning that\n+\t// Front points to the latest tpBucket and Back to the oldest one.\n+\tbuffer *list.List\n+\n+\t// A RWMutex guards all operations on the underlying buffer.\n+\tsync.RWMutex\n+\n+\t// epsilon is the acceptable error difference for the storage of TimePoints.\n+\t// Increasing epsilon decreases the memory usage of the statStore, at the cost of precision.\n+\t// The precision of max is not affected.\n+\tepsilon uint64","path":"store/stat_store.go","position":56,"original_position":56,"commit_id":"a8becf294bc3439788f1b16f4a020bf2744f8b58","original_commit_id":"a8becf294bc3439788f1b16f4a020bf2744f8b58","user":{"login":"mvdan","id":3576549,"avatar_url":"https://avatars.githubusercontent.com/u/3576549?v=3","gravatar_id":"","url":"https://api.github.com/users/mvdan","html_url":"https://github.com/mvdan","followers_url":"https://api.github.com/users/mvdan/followers","following_url":"https://api.github.com/users/mvdan/following{/other_user}","gists_url":"https://api.github.com/users/mvdan/gists{/gist_id}","starred_url":"https://api.github.com/users/mvdan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvdan/subscriptions","organizations_url":"https://api.github.com/users/mvdan/orgs","repos_url":"https://api.github.com/users/mvdan/repos","events_url":"https://api.github.com/users/mvdan/events{/privacy}","received_events_url":"https://api.github.com/users/mvdan/received_events","type":"User","site_admin":false},"body":"Why did you choose to make epsilon `uint64` instead of `float64`?","created_at":"2015-08-12T17:46:36Z","updated_at":"2015-08-12T17:46:36Z","html_url":"https://github.com/kubernetes/heapster/pull/461#discussion_r36890698","pull_request_url":"https://api.github.com/repos/kubernetes/heapster/pulls/461","_links":{"self":{"href":"https://api.github.com/repos/kubernetes/heapster/pulls/comments/36890698"},"html":{"href":"https://github.com/kubernetes/heapster/pull/461#discussion_r36890698"},"pull_request":{"href":"https://api.github.com/repos/kubernetes/heapster/pulls/461"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes/heapster/pulls/461","id":42043934,"html_url":"https://github.com/kubernetes/heapster/pull/461","diff_url":"https://github.com/kubernetes/heapster/pull/461.diff","patch_url":"https://github.com/kubernetes/heapster/pull/461.patch","issue_url":"https://api.github.com/repos/kubernetes/heapster/issues/461","number":461,"state":"open","locked":false,"title":"Time and value-compressible statStore","user":{"login":"afein","id":680441,"avatar_url":"https://avatars.githubusercontent.com/u/680441?v=3","gravatar_id":"","url":"https://api.github.com/users/afein","html_url":"https://github.com/afein","followers_url":"https://api.github.com/users/afein/followers","following_url":"https://api.github.com/users/afein/following{/other_user}","gists_url":"https://api.github.com/users/afein/gists{/gist_id}","starred_url":"https://api.github.com/users/afein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afein/subscriptions","organizations_url":"https://api.github.com/users/afein/orgs","repos_url":"https://api.github.com/users/afein/repos","events_url":"https://api.github.com/users/afein/events{/privacy}","received_events_url":"https://api.github.com/users/afein/received_events","type":"User","site_admin":false},"body":"\\cc @vishh\r\n\r\nThis statStore can be configured to make tradeoffs between precision and memory consumption though the epsilon and resolution arguments.","created_at":"2015-08-10T17:20:40Z","updated_at":"2015-08-12T17:46:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ef9e54dcbf7ad2272ba78b268ad78223697ff5b9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes/heapster/pulls/461/commits","review_comments_url":"https://api.github.com/repos/kubernetes/heapster/pulls/461/comments","review_comment_url":"https://api.github.com/repos/kubernetes/heapster/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes/heapster/issues/461/comments","statuses_url":"https://api.github.com/repos/kubernetes/heapster/statuses/a8becf294bc3439788f1b16f4a020bf2744f8b58","head":{"label":"afein:stat_store_struct","ref":"stat_store_struct","sha":"a8becf294bc3439788f1b16f4a020bf2744f8b58","user":{"login":"afein","id":680441,"avatar_url":"https://avatars.githubusercontent.com/u/680441?v=3","gravatar_id":"","url":"https://api.github.com/users/afein","html_url":"https://github.com/afein","followers_url":"https://api.github.com/users/afein/followers","following_url":"https://api.github.com/users/afein/following{/other_user}","gists_url":"https://api.github.com/users/afein/gists{/gist_id}","starred_url":"https://api.github.com/users/afein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afein/subscriptions","organizations_url":"https://api.github.com/users/afein/orgs","repos_url":"https://api.github.com/users/afein/repos","events_url":"https://api.github.com/users/afein/events{/privacy}","received_events_url":"https://api.github.com/users/afein/received_events","type":"User","site_admin":false},"repo":{"id":36956080,"name":"heapster","full_name":"afein/heapster","owner":{"login":"afein","id":680441,"avatar_url":"https://avatars.githubusercontent.com/u/680441?v=3","gravatar_id":"","url":"https://api.github.com/users/afein","html_url":"https://github.com/afein","followers_url":"https://api.github.com/users/afein/followers","following_url":"https://api.github.com/users/afein/following{/other_user}","gists_url":"https://api.github.com/users/afein/gists{/gist_id}","starred_url":"https://api.github.com/users/afein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afein/subscriptions","organizations_url":"https://api.github.com/users/afein/orgs","repos_url":"https://api.github.com/users/afein/repos","events_url":"https://api.github.com/users/afein/events{/privacy}","received_events_url":"https://api.github.com/users/afein/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/afein/heapster","description":"Monitor container resource usage of a Kubernetes cluster","fork":true,"url":"https://api.github.com/repos/afein/heapster","forks_url":"https://api.github.com/repos/afein/heapster/forks","keys_url":"https://api.github.com/repos/afein/heapster/keys{/key_id}","collaborators_url":"https://api.github.com/repos/afein/heapster/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/afein/heapster/teams","hooks_url":"https://api.github.com/repos/afein/heapster/hooks","issue_events_url":"https://api.github.com/repos/afein/heapster/issues/events{/number}","events_url":"https://api.github.com/repos/afein/heapster/events","assignees_url":"https://api.github.com/repos/afein/heapster/assignees{/user}","branches_url":"https://api.github.com/repos/afein/heapster/branches{/branch}","tags_url":"https://api.github.com/repos/afein/heapster/tags","blobs_url":"https://api.github.com/repos/afein/heapster/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/afein/heapster/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/afein/heapster/git/refs{/sha}","trees_url":"https://api.github.com/repos/afein/heapster/git/trees{/sha}","statuses_url":"https://api.github.com/repos/afein/heapster/statuses/{sha}","languages_url":"https://api.github.com/repos/afein/heapster/languages","stargazers_url":"https://api.github.com/repos/afein/heapster/stargazers","contributors_url":"https://api.github.com/repos/afein/heapster/contributors","subscribers_url":"https://api.github.com/repos/afein/heapster/subscribers","subscription_url":"https://api.github.com/repos/afein/heapster/subscription","commits_url":"https://api.github.com/repos/afein/heapster/commits{/sha}","git_commits_url":"https://api.github.com/repos/afein/heapster/git/commits{/sha}","comments_url":"https://api.github.com/repos/afein/heapster/comments{/number}","issue_comment_url":"https://api.github.com/repos/afein/heapster/issues/comments{/number}","contents_url":"https://api.github.com/repos/afein/heapster/contents/{+path}","compare_url":"https://api.github.com/repos/afein/heapster/compare/{base}...{head}","merges_url":"https://api.github.com/repos/afein/heapster/merges","archive_url":"https://api.github.com/repos/afein/heapster/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/afein/heapster/downloads","issues_url":"https://api.github.com/repos/afein/heapster/issues{/number}","pulls_url":"https://api.github.com/repos/afein/heapster/pulls{/number}","milestones_url":"https://api.github.com/repos/afein/heapster/milestones{/number}","notifications_url":"https://api.github.com/repos/afein/heapster/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/afein/heapster/labels{/name}","releases_url":"https://api.github.com/repos/afein/heapster/releases{/id}","created_at":"2015-06-05T21:24:01Z","updated_at":"2015-06-05T21:24:02Z","pushed_at":"2015-08-12T06:57:56Z","git_url":"git://github.com/afein/heapster.git","ssh_url":"git@github.com:afein/heapster.git","clone_url":"https://github.com/afein/heapster.git","svn_url":"https://github.com/afein/heapster","homepage":"","size":19970,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"kubernetes:master","ref":"master","sha":"a46624e66bd59c658f2fc7c2fdecedc6c2a3fc9f","user":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"repo":{"id":23272510,"name":"heapster","full_name":"kubernetes/heapster","owner":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kubernetes/heapster","description":"Compute Resource Usage Analysis and Monitoring of Container Clusters","fork":false,"url":"https://api.github.com/repos/kubernetes/heapster","forks_url":"https://api.github.com/repos/kubernetes/heapster/forks","keys_url":"https://api.github.com/repos/kubernetes/heapster/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kubernetes/heapster/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kubernetes/heapster/teams","hooks_url":"https://api.github.com/repos/kubernetes/heapster/hooks","issue_events_url":"https://api.github.com/repos/kubernetes/heapster/issues/events{/number}","events_url":"https://api.github.com/repos/kubernetes/heapster/events","assignees_url":"https://api.github.com/repos/kubernetes/heapster/assignees{/user}","branches_url":"https://api.github.com/repos/kubernetes/heapster/branches{/branch}","tags_url":"https://api.github.com/repos/kubernetes/heapster/tags","blobs_url":"https://api.github.com/repos/kubernetes/heapster/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kubernetes/heapster/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kubernetes/heapster/git/refs{/sha}","trees_url":"https://api.github.com/repos/kubernetes/heapster/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kubernetes/heapster/statuses/{sha}","languages_url":"https://api.github.com/repos/kubernetes/heapster/languages","stargazers_url":"https://api.github.com/repos/kubernetes/heapster/stargazers","contributors_url":"https://api.github.com/repos/kubernetes/heapster/contributors","subscribers_url":"https://api.github.com/repos/kubernetes/heapster/subscribers","subscription_url":"https://api.github.com/repos/kubernetes/heapster/subscription","commits_url":"https://api.github.com/repos/kubernetes/heapster/commits{/sha}","git_commits_url":"https://api.github.com/repos/kubernetes/heapster/git/commits{/sha}","comments_url":"https://api.github.com/repos/kubernetes/heapster/comments{/number}","issue_comment_url":"https://api.github.com/repos/kubernetes/heapster/issues/comments{/number}","contents_url":"https://api.github.com/repos/kubernetes/heapster/contents/{+path}","compare_url":"https://api.github.com/repos/kubernetes/heapster/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kubernetes/heapster/merges","archive_url":"https://api.github.com/repos/kubernetes/heapster/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kubernetes/heapster/downloads","issues_url":"https://api.github.com/repos/kubernetes/heapster/issues{/number}","pulls_url":"https://api.github.com/repos/kubernetes/heapster/pulls{/number}","milestones_url":"https://api.github.com/repos/kubernetes/heapster/milestones{/number}","notifications_url":"https://api.github.com/repos/kubernetes/heapster/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kubernetes/heapster/labels{/name}","releases_url":"https://api.github.com/repos/kubernetes/heapster/releases{/id}","created_at":"2014-08-24T03:50:18Z","updated_at":"2015-08-12T14:18:15Z","pushed_at":"2015-08-12T02:01:11Z","git_url":"git://github.com/kubernetes/heapster.git","ssh_url":"git@github.com:kubernetes/heapster.git","clone_url":"https://github.com/kubernetes/heapster.git","svn_url":"https://github.com/kubernetes/heapster","homepage":"","size":22863,"stargazers_count":371,"watchers_count":371,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":99,"mirror_url":null,"open_issues_count":80,"forks":99,"open_issues":80,"watchers":371,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes/heapster/pulls/461"},"html":{"href":"https://github.com/kubernetes/heapster/pull/461"},"issue":{"href":"https://api.github.com/repos/kubernetes/heapster/issues/461"},"comments":{"href":"https://api.github.com/repos/kubernetes/heapster/issues/461/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes/heapster/pulls/461/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes/heapster/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes/heapster/pulls/461/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes/heapster/statuses/a8becf294bc3439788f1b16f4a020bf2744f8b58"}}}}