GitHub PullRequestReviewCommentEvent at 2014-08-22 11:21:34
Repository: collectd
Actor: mfournier
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/collectd/collectd/pulls/comments/16592837","id":16592837,"diff_hunk":"@@ -83,17 +92,93 @@ void latency_counter_add (latency_counter_t *lc, cdtime_t latency) /* {{{ */\n    * subtract one from the cdtime_t value so that exactly 1.0 ms get sorted\n    * accordingly. */\n   latency_ms = (size_t) CDTIME_T_TO_MS (latency - 1);\n+  if ((latency_ms > 0) && (lc->bucket_width > 1))\n+    latency_ms /= lc->bucket_width;\n+\n   if (latency_ms < STATIC_ARRAY_SIZE (lc->histogram))\n     lc->histogram[latency_ms]++;\n+  else\n+    lc->histogram[lc->no_buckets - 1]++;\n } /* }}} void latency_counter_add */\n \n+static void latency_counter_autofocus(latency_counter_t *lc) /* {{{ */\n+{\n+  /* check whether our maximum is outside of the histogram: */\n+  if ((lc->num > MIN_COUNT_FOR_AUTOFOCUS) &&\n+      (lc->max > lc->bucket_width * lc->no_buckets)) {\n+    uint64_t count = 0;\n+    int i;\n+\n+    /* we look into the upper most 3 buckets, whether\n+     * they contain a significant amount of values\n+     */\n+    for (i=lc->no_buckets; i > lc->no_buckets - 3; i--)\n+      count = lc->histogram[i];\n+\n+    /* are more than 10% in the upper area of the histogram? */\n+    if (count > lc->num * 0.1)\n+    {\n+      int old_bucket_width = lc->bucket_width;\n+      int new_histogram_max = lc->sum / lc->num * 2;\n+\n+      /* our histogram should be able to cope the double of our average. */\n+      while (new_histogram_max > lc->bucket_width * lc->no_buckets)\n+        lc->bucket_width++;\n+\n+      INFO(\"Latency counter: refucusing %s from bucket width %d to %d\",\n+           lc->name, old_bucket_width, lc->bucket_width);\n+    }\n+  }\n+  else if (lc->num > MIN_COUNT_FOR_AUTOFOCUS) {\n+    /* check for underexposure */\n+    uint64_t count = 0;\n+    int i;\n+\n+    /* we look into the first 3 buckets, whether\n+     * they contain a significant amount of values\n+     */\n+    for (i=0; i > 3; i++)\n+      count = lc->histogram[i];\n+\n+    /* is it more than 90% of our values? */\n+    if (count > lc->num * 0.9)\n+    {\n+      int old_bucket_width = lc->bucket_width;\n+      int new_histogram_max = lc->sum / lc->num * 2;\n+\n+      while ((lc->bucket_width > 1) &&\n+             (new_histogram_max > lc->bucket_width * lc->no_buckets))\n+        lc->bucket_width--;\n+\n+      INFO(\"Latency counter: refucusing %s from bucket width %d to %d\",\n+           lc->name, old_bucket_width, lc->bucket_width);\n+    }\n+  }\n+} /* }}} void latency_counter_autofocus */\n+\n void latency_counter_reset (latency_counter_t *lc) /* {{{ */\n {\n+  int bucket_width;\n+  int no_buckets;\n+  const char *name;\n+\n   if (lc == NULL)\n     return;\n \n-  memset (lc, 0, sizeof (*lc));\n+  latency_counter_autofocus(lc);\n+\n+  bucket_width = lc->bucket_width;\n+  no_buckets = lc->no_buckets;\n+  name = lc->name;\n+\n+  memset (lc, 0, sizeof (*lc) + no_buckets * sizeof(uint64_t));\n   lc->start_time = cdtime ();\n+  lc->bucket_width = bucket_width;\n+  lc->no_buckets = no_buckets;\n+  lc->name = name;\n+\n+  /* the memory area of the histogram is right after the struct */\n+  lc->histogram = (uint64_t *)(&lc->histogram) + 1;","path":"src/utils_latency.c","position":134,"original_position":134,"commit_id":"13e12b5045725be705fb1debb42620c8eff311a7","original_commit_id":"13e12b5045725be705fb1debb42620c8eff311a7","user":{"login":"mfournier","id":37533,"avatar_url":"https://avatars.githubusercontent.com/u/37533?v=2","gravatar_id":null,"url":"https://api.github.com/users/mfournier","html_url":"https://github.com/mfournier","followers_url":"https://api.github.com/users/mfournier/followers","following_url":"https://api.github.com/users/mfournier/following{/other_user}","gists_url":"https://api.github.com/users/mfournier/gists{/gist_id}","starred_url":"https://api.github.com/users/mfournier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mfournier/subscriptions","organizations_url":"https://api.github.com/users/mfournier/orgs","repos_url":"https://api.github.com/users/mfournier/repos","events_url":"https://api.github.com/users/mfournier/events{/privacy}","received_events_url":"https://api.github.com/users/mfournier/received_events","type":"User","site_admin":false},"body":"So using `lc->histogram = (uint64_t *)((void *)&lc->histogram) + 1;` here makes the code build with prehistoric gcc versions.\r\n\r\nBut I have no idea if this might have side effects, and don't have a test environment setup for this ATM.","created_at":"2014-08-22T11:21:34Z","updated_at":"2014-08-22T11:21:34Z","html_url":"https://github.com/collectd/collectd/pull/637#discussion_r16592837","pull_request_url":"https://api.github.com/repos/collectd/collectd/pulls/637","_links":{"self":{"href":"https://api.github.com/repos/collectd/collectd/pulls/comments/16592837"},"html":{"href":"https://github.com/collectd/collectd/pull/637#discussion_r16592837"},"pull_request":{"href":"https://api.github.com/repos/collectd/collectd/pulls/637"}}},"pull_request":{"url":"https://api.github.com/repos/collectd/collectd/pulls/637","id":16853176,"html_url":"https://github.com/collectd/collectd/pull/637","diff_url":"https://github.com/collectd/collectd/pull/637.diff","patch_url":"https://github.com/collectd/collectd/pull/637.patch","issue_url":"https://api.github.com/repos/collectd/collectd/issues/637","number":637,"state":"open","locked":false,"title":"Statsd flexible histogram","user":{"login":"dothebart","id":5013077,"avatar_url":"https://avatars.githubusercontent.com/u/5013077?v=2","gravatar_id":"5e9784db3d8d73ba92a45847fb05340f","url":"https://api.github.com/users/dothebart","html_url":"https://github.com/dothebart","followers_url":"https://api.github.com/users/dothebart/followers","following_url":"https://api.github.com/users/dothebart/following{/other_user}","gists_url":"https://api.github.com/users/dothebart/gists{/gist_id}","starred_url":"https://api.github.com/users/dothebart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dothebart/subscriptions","organizations_url":"https://api.github.com/users/dothebart/orgs","repos_url":"https://api.github.com/users/dothebart/repos","events_url":"https://api.github.com/users/dothebart/events{/privacy}","received_events_url":"https://api.github.com/users/dothebart/received_events","type":"User","site_admin":false},"body":"The collectd Statsd implementation currently will only accept values in the range from 0 - 1000 in the histogram it uses to calculate the percentile. In case of of values > 1000 these will be ignored; the Histogram is to be compared to an over exposure photo. \r\nTo be able to adopt to other usecases the range of the histogramm has to become flexible so the user can configure the range of values his data series generate.\r\n\r\n(fixes #401)\r\n","created_at":"2014-06-07T10:12:33Z","updated_at":"2014-08-22T11:21:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"68df53beccb4c540158b3f25b60b233b4f1ead31","assignee":{"login":"mfournier","id":37533,"avatar_url":"https://avatars.githubusercontent.com/u/37533?v=2","gravatar_id":null,"url":"https://api.github.com/users/mfournier","html_url":"https://github.com/mfournier","followers_url":"https://api.github.com/users/mfournier/followers","following_url":"https://api.github.com/users/mfournier/following{/other_user}","gists_url":"https://api.github.com/users/mfournier/gists{/gist_id}","starred_url":"https://api.github.com/users/mfournier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mfournier/subscriptions","organizations_url":"https://api.github.com/users/mfournier/orgs","repos_url":"https://api.github.com/users/mfournier/repos","events_url":"https://api.github.com/users/mfournier/events{/privacy}","received_events_url":"https://api.github.com/users/mfournier/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/collectd/collectd/pulls/637/commits","review_comments_url":"https://api.github.com/repos/collectd/collectd/pulls/637/comments","review_comment_url":"https://api.github.com/repos/collectd/collectd/pulls/comments/{number}","comments_url":"https://api.github.com/repos/collectd/collectd/issues/637/comments","statuses_url":"https://api.github.com/repos/collectd/collectd/statuses/13e12b5045725be705fb1debb42620c8eff311a7","head":{"label":"dothebart:statsd_flexible_histogram","ref":"statsd_flexible_histogram","sha":"13e12b5045725be705fb1debb42620c8eff311a7","user":{"login":"dothebart","id":5013077,"avatar_url":"https://avatars.githubusercontent.com/u/5013077?v=2","gravatar_id":"5e9784db3d8d73ba92a45847fb05340f","url":"https://api.github.com/users/dothebart","html_url":"https://github.com/dothebart","followers_url":"https://api.github.com/users/dothebart/followers","following_url":"https://api.github.com/users/dothebart/following{/other_user}","gists_url":"https://api.github.com/users/dothebart/gists{/gist_id}","starred_url":"https://api.github.com/users/dothebart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dothebart/subscriptions","organizations_url":"https://api.github.com/users/dothebart/orgs","repos_url":"https://api.github.com/users/dothebart/repos","events_url":"https://api.github.com/users/dothebart/events{/privacy}","received_events_url":"https://api.github.com/users/dothebart/received_events","type":"User","site_admin":false},"repo":{"id":12902584,"name":"collectd","full_name":"dothebart/collectd","owner":{"login":"dothebart","id":5013077,"avatar_url":"https://avatars.githubusercontent.com/u/5013077?v=2","gravatar_id":"5e9784db3d8d73ba92a45847fb05340f","url":"https://api.github.com/users/dothebart","html_url":"https://github.com/dothebart","followers_url":"https://api.github.com/users/dothebart/followers","following_url":"https://api.github.com/users/dothebart/following{/other_user}","gists_url":"https://api.github.com/users/dothebart/gists{/gist_id}","starred_url":"https://api.github.com/users/dothebart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dothebart/subscriptions","organizations_url":"https://api.github.com/users/dothebart/orgs","repos_url":"https://api.github.com/users/dothebart/repos","events_url":"https://api.github.com/users/dothebart/events{/privacy}","received_events_url":"https://api.github.com/users/dothebart/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dothebart/collectd","description":"The system statistics collection daemon. Mirror of the canonical repository (updated automatically). Please send Pull Requests here!","fork":true,"url":"https://api.github.com/repos/dothebart/collectd","forks_url":"https://api.github.com/repos/dothebart/collectd/forks","keys_url":"https://api.github.com/repos/dothebart/collectd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dothebart/collectd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dothebart/collectd/teams","hooks_url":"https://api.github.com/repos/dothebart/collectd/hooks","issue_events_url":"https://api.github.com/repos/dothebart/collectd/issues/events{/number}","events_url":"https://api.github.com/repos/dothebart/collectd/events","assignees_url":"https://api.github.com/repos/dothebart/collectd/assignees{/user}","branches_url":"https://api.github.com/repos/dothebart/collectd/branches{/branch}","tags_url":"https://api.github.com/repos/dothebart/collectd/tags","blobs_url":"https://api.github.com/repos/dothebart/collectd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dothebart/collectd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dothebart/collectd/git/refs{/sha}","trees_url":"https://api.github.com/repos/dothebart/collectd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dothebart/collectd/statuses/{sha}","languages_url":"https://api.github.com/repos/dothebart/collectd/languages","stargazers_url":"https://api.github.com/repos/dothebart/collectd/stargazers","contributors_url":"https://api.github.com/repos/dothebart/collectd/contributors","subscribers_url":"https://api.github.com/repos/dothebart/collectd/subscribers","subscription_url":"https://api.github.com/repos/dothebart/collectd/subscription","commits_url":"https://api.github.com/repos/dothebart/collectd/commits{/sha}","git_commits_url":"https://api.github.com/repos/dothebart/collectd/git/commits{/sha}","comments_url":"https://api.github.com/repos/dothebart/collectd/comments{/number}","issue_comment_url":"https://api.github.com/repos/dothebart/collectd/issues/comments/{number}","contents_url":"https://api.github.com/repos/dothebart/collectd/contents/{+path}","compare_url":"https://api.github.com/repos/dothebart/collectd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dothebart/collectd/merges","archive_url":"https://api.github.com/repos/dothebart/collectd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dothebart/collectd/downloads","issues_url":"https://api.github.com/repos/dothebart/collectd/issues{/number}","pulls_url":"https://api.github.com/repos/dothebart/collectd/pulls{/number}","milestones_url":"https://api.github.com/repos/dothebart/collectd/milestones{/number}","notifications_url":"https://api.github.com/repos/dothebart/collectd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dothebart/collectd/labels{/name}","releases_url":"https://api.github.com/repos/dothebart/collectd/releases{/id}","created_at":"2013-09-17T17:52:35Z","updated_at":"2014-06-23T17:24:59Z","pushed_at":"2014-08-17T18:18:36Z","git_url":"git://github.com/dothebart/collectd.git","ssh_url":"git@github.com:dothebart/collectd.git","clone_url":"https://github.com/dothebart/collectd.git","svn_url":"https://github.com/dothebart/collectd","homepage":"http://collectd.org/","size":8686,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"collectd:master","ref":"master","sha":"d76d25155399943bc9d317c6fb6d1981ca6e9b00","user":{"login":"collectd","id":1027481,"avatar_url":"https://avatars.githubusercontent.com/u/1027481?v=2","gravatar_id":"188b407182480323a08c11bff0b14cad","url":"https://api.github.com/users/collectd","html_url":"https://github.com/collectd","followers_url":"https://api.github.com/users/collectd/followers","following_url":"https://api.github.com/users/collectd/following{/other_user}","gists_url":"https://api.github.com/users/collectd/gists{/gist_id}","starred_url":"https://api.github.com/users/collectd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/collectd/subscriptions","organizations_url":"https://api.github.com/users/collectd/orgs","repos_url":"https://api.github.com/users/collectd/repos","events_url":"https://api.github.com/users/collectd/events{/privacy}","received_events_url":"https://api.github.com/users/collectd/received_events","type":"Organization","site_admin":false},"repo":{"id":3208640,"name":"collectd","full_name":"collectd/collectd","owner":{"login":"collectd","id":1027481,"avatar_url":"https://avatars.githubusercontent.com/u/1027481?v=2","gravatar_id":"188b407182480323a08c11bff0b14cad","url":"https://api.github.com/users/collectd","html_url":"https://github.com/collectd","followers_url":"https://api.github.com/users/collectd/followers","following_url":"https://api.github.com/users/collectd/following{/other_user}","gists_url":"https://api.github.com/users/collectd/gists{/gist_id}","starred_url":"https://api.github.com/users/collectd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/collectd/subscriptions","organizations_url":"https://api.github.com/users/collectd/orgs","repos_url":"https://api.github.com/users/collectd/repos","events_url":"https://api.github.com/users/collectd/events{/privacy}","received_events_url":"https://api.github.com/users/collectd/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/collectd/collectd","description":"The system statistics collection daemon. Mirror of the canonical repository (updated automatically). Please send Pull Requests here!","fork":false,"url":"https://api.github.com/repos/collectd/collectd","forks_url":"https://api.github.com/repos/collectd/collectd/forks","keys_url":"https://api.github.com/repos/collectd/collectd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/collectd/collectd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/collectd/collectd/teams","hooks_url":"https://api.github.com/repos/collectd/collectd/hooks","issue_events_url":"https://api.github.com/repos/collectd/collectd/issues/events{/number}","events_url":"https://api.github.com/repos/collectd/collectd/events","assignees_url":"https://api.github.com/repos/collectd/collectd/assignees{/user}","branches_url":"https://api.github.com/repos/collectd/collectd/branches{/branch}","tags_url":"https://api.github.com/repos/collectd/collectd/tags","blobs_url":"https://api.github.com/repos/collectd/collectd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/collectd/collectd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/collectd/collectd/git/refs{/sha}","trees_url":"https://api.github.com/repos/collectd/collectd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/collectd/collectd/statuses/{sha}","languages_url":"https://api.github.com/repos/collectd/collectd/languages","stargazers_url":"https://api.github.com/repos/collectd/collectd/stargazers","contributors_url":"https://api.github.com/repos/collectd/collectd/contributors","subscribers_url":"https://api.github.com/repos/collectd/collectd/subscribers","subscription_url":"https://api.github.com/repos/collectd/collectd/subscription","commits_url":"https://api.github.com/repos/collectd/collectd/commits{/sha}","git_commits_url":"https://api.github.com/repos/collectd/collectd/git/commits{/sha}","comments_url":"https://api.github.com/repos/collectd/collectd/comments{/number}","issue_comment_url":"https://api.github.com/repos/collectd/collectd/issues/comments/{number}","contents_url":"https://api.github.com/repos/collectd/collectd/contents/{+path}","compare_url":"https://api.github.com/repos/collectd/collectd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/collectd/collectd/merges","archive_url":"https://api.github.com/repos/collectd/collectd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/collectd/collectd/downloads","issues_url":"https://api.github.com/repos/collectd/collectd/issues{/number}","pulls_url":"https://api.github.com/repos/collectd/collectd/pulls{/number}","milestones_url":"https://api.github.com/repos/collectd/collectd/milestones{/number}","notifications_url":"https://api.github.com/repos/collectd/collectd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/collectd/collectd/labels{/name}","releases_url":"https://api.github.com/repos/collectd/collectd/releases{/id}","created_at":"2012-01-18T13:07:51Z","updated_at":"2014-08-22T01:50:17Z","pushed_at":"2014-08-22T07:53:35Z","git_url":"git://github.com/collectd/collectd.git","ssh_url":"git@github.com:collectd/collectd.git","clone_url":"https://github.com/collectd/collectd.git","svn_url":"https://github.com/collectd/collectd","homepage":"http://collectd.org/","size":19895,"stargazers_count":457,"watchers_count":457,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"forks_count":331,"mirror_url":null,"open_issues_count":167,"forks":331,"open_issues":167,"watchers":457,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/collectd/collectd/pulls/637"},"html":{"href":"https://github.com/collectd/collectd/pull/637"},"issue":{"href":"https://api.github.com/repos/collectd/collectd/issues/637"},"comments":{"href":"https://api.github.com/repos/collectd/collectd/issues/637/comments"},"review_comments":{"href":"https://api.github.com/repos/collectd/collectd/pulls/637/comments"},"review_comment":{"href":"https://api.github.com/repos/collectd/collectd/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/collectd/collectd/pulls/637/commits"},"statuses":{"href":"https://api.github.com/repos/collectd/collectd/statuses/13e12b5045725be705fb1debb42620c8eff311a7"}}}}