{"action":"created","comment":{"url":"https://api.github.com/repos/prometheus/prometheus/pulls/comments/32527781","id":32527781,"diff_hunk":"@@ -336,67 +336,96 @@ func (s *memorySeriesStorage) NewPreloader() Preloader {\n \t}\n }\n \n-// FingerprintsForLabelMatchers implements Storage.\n-func (s *memorySeriesStorage) FingerprintsForLabelMatchers(labelMatchers metric.LabelMatchers) clientmodel.Fingerprints {\n+// FingerprintsForLabels implements Storage.\n+func (s *memorySeriesStorage) FingerprintsForLabels(pairs ...metric.LabelPair) map[clientmodel.Fingerprint]struct{} {\n \tvar result map[clientmodel.Fingerprint]struct{}\n-\tfor _, matcher := range labelMatchers {\n+\tfor _, pair := range pairs {\n \t\tintersection := map[clientmodel.Fingerprint]struct{}{}\n-\t\tswitch matcher.Type {\n-\t\tcase metric.Equal:\n-\t\t\tfps, err := s.persistence.fingerprintsForLabelPair(\n-\t\t\t\tmetric.LabelPair{\n-\t\t\t\t\tName:  matcher.Name,\n-\t\t\t\t\tValue: matcher.Value,\n-\t\t\t\t},\n-\t\t\t)\n-\t\t\tif err != nil {\n-\t\t\t\tlog.Error(\"Error getting fingerprints for label pair: \", err)\n-\t\t\t}\n-\t\t\tif len(fps) == 0 {\n-\t\t\t\treturn nil\n-\t\t\t}\n-\t\t\tfor _, fp := range fps {\n-\t\t\t\tif _, ok := result[fp]; ok || result == nil {\n-\t\t\t\t\tintersection[fp] = struct{}{}\n-\t\t\t\t}\n+\t\tfps, err := s.persistence.fingerprintsForLabelPair(pair)\n+\t\tif err != nil {\n+\t\t\tlog.Error(\"Error getting fingerprints for label pair: \", err)\n+\t\t}\n+\t\tif len(fps) == 0 {\n+\t\t\treturn nil\n+\t\t}\n+\t\tfor _, fp := range fps {\n+\t\t\tif _, ok := result[fp]; ok || result == nil {\n+\t\t\t\tintersection[fp] = struct{}{}\n \t\t\t}\n-\t\tdefault:\n-\t\t\tvalues, err := s.persistence.labelValuesForLabelName(matcher.Name)\n-\t\t\tif err != nil {\n-\t\t\t\tlog.Errorf(\"Error getting label values for label name %q: %v\", matcher.Name, err)\n+\t\t}\n+\t\tif len(intersection) == 0 {\n+\t\t\treturn nil\n+\t\t}\n+\t\tresult = intersection\n+\t}\n+\treturn result\n+}\n+\n+// MetricsForLabelMatchers returns the metrics from storage that satisfy the given label matchers.\n+func MetricsForLabelMatchers(storage Storage, matchers ...*metric.LabelMatcher) map[clientmodel.Fingerprint]clientmodel.COWMetric {\n+\tvar (\n+\t\tequals  []metric.LabelPair","path":"storage/local/storage.go","position":57,"original_position":57,"commit_id":"5de5baa2843e2d9f845ce54b8e4dc0134656f491","original_commit_id":"5de5baa2843e2d9f845ce54b8e4dc0134656f491","user":{"login":"juliusv","id":538008,"avatar_url":"https://avatars.githubusercontent.com/u/538008?v=3","gravatar_id":"","url":"https://api.github.com/users/juliusv","html_url":"https://github.com/juliusv","followers_url":"https://api.github.com/users/juliusv/followers","following_url":"https://api.github.com/users/juliusv/following{/other_user}","gists_url":"https://api.github.com/users/juliusv/gists{/gist_id}","starred_url":"https://api.github.com/users/juliusv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juliusv/subscriptions","organizations_url":"https://api.github.com/users/juliusv/orgs","repos_url":"https://api.github.com/users/juliusv/repos","events_url":"https://api.github.com/users/juliusv/events{/privacy}","received_events_url":"https://api.github.com/users/juliusv/received_events","type":"User","site_admin":false},"body":"We have different perceptions then. We should still agree on one style vs. the other generally. Doesn't have to be now, because there's more important things to worry about...","created_at":"2015-06-16T14:43:50Z","updated_at":"2015-06-16T14:43:50Z","html_url":"https://github.com/prometheus/prometheus/pull/810#discussion_r32527781","pull_request_url":"https://api.github.com/repos/prometheus/prometheus/pulls/810","_links":{"self":{"href":"https://api.github.com/repos/prometheus/prometheus/pulls/comments/32527781"},"html":{"href":"https://github.com/prometheus/prometheus/pull/810#discussion_r32527781"},"pull_request":{"href":"https://api.github.com/repos/prometheus/prometheus/pulls/810"}}},"pull_request":{"url":"https://api.github.com/repos/prometheus/prometheus/pulls/810","id":37712185,"html_url":"https://github.com/prometheus/prometheus/pull/810","diff_url":"https://github.com/prometheus/prometheus/pull/810.diff","patch_url":"https://github.com/prometheus/prometheus/pull/810.patch","issue_url":"https://api.github.com/repos/prometheus/prometheus/issues/810","number":810,"state":"open","locked":false,"title":"Match empty labels.","user":{"login":"fabxc","id":4948210,"avatar_url":"https://avatars.githubusercontent.com/u/4948210?v=3","gravatar_id":"","url":"https://api.github.com/users/fabxc","html_url":"https://github.com/fabxc","followers_url":"https://api.github.com/users/fabxc/followers","following_url":"https://api.github.com/users/fabxc/following{/other_user}","gists_url":"https://api.github.com/users/fabxc/gists{/gist_id}","starred_url":"https://api.github.com/users/fabxc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabxc/subscriptions","organizations_url":"https://api.github.com/users/fabxc/orgs","repos_url":"https://api.github.com/users/fabxc/repos","events_url":"https://api.github.com/users/fabxc/events{/privacy}","received_events_url":"https://api.github.com/users/fabxc/received_events","type":"User","site_admin":false},"body":"This changes the strategy for resolving label matchers. The general idea is that manual label comparison on a very limited base set is cheaper than intersecting it with many, possibly very large, sets of fingerprints for other matchers.\r\n\r\nFirst, we resolve all equality matches except for empty ones (that's what our indexes actually support). If there are none, we do the old expand+intersect as this is most likely still better than getting all fingerprints.\r\n\r\nWith the resulting base set of fingerprints we manually resolve any empty equality-matching and regex and not-equal matchers (if we had non-empty equality matchers initially).\r\n\r\nWe could improve in the stage of getting equality matches. Getting the ones with the most different label values first is a possible approach but we currently do not have any information on the partitions of label dimensions. Thus, the benefit cannot be generalized and and I left it out for now.\r\n\r\n@beorn7 @juliusv @brian-brazil ","created_at":"2015-06-15T16:52:03Z","updated_at":"2015-06-16T14:43:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2bcf23fc05616c57348261d890eabf2751c7d46b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/prometheus/prometheus/pulls/810/commits","review_comments_url":"https://api.github.com/repos/prometheus/prometheus/pulls/810/comments","review_comment_url":"https://api.github.com/repos/prometheus/prometheus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prometheus/prometheus/issues/810/comments","statuses_url":"https://api.github.com/repos/prometheus/prometheus/statuses/5de5baa2843e2d9f845ce54b8e4dc0134656f491","head":{"label":"prometheus:fabxc/lmatch","ref":"fabxc/lmatch","sha":"5de5baa2843e2d9f845ce54b8e4dc0134656f491","user":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"repo":{"id":6838921,"name":"prometheus","full_name":"prometheus/prometheus","owner":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prometheus/prometheus","description":"The Prometheus monitoring system and time series database.","fork":false,"url":"https://api.github.com/repos/prometheus/prometheus","forks_url":"https://api.github.com/repos/prometheus/prometheus/forks","keys_url":"https://api.github.com/repos/prometheus/prometheus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prometheus/prometheus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prometheus/prometheus/teams","hooks_url":"https://api.github.com/repos/prometheus/prometheus/hooks","issue_events_url":"https://api.github.com/repos/prometheus/prometheus/issues/events{/number}","events_url":"https://api.github.com/repos/prometheus/prometheus/events","assignees_url":"https://api.github.com/repos/prometheus/prometheus/assignees{/user}","branches_url":"https://api.github.com/repos/prometheus/prometheus/branches{/branch}","tags_url":"https://api.github.com/repos/prometheus/prometheus/tags","blobs_url":"https://api.github.com/repos/prometheus/prometheus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prometheus/prometheus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prometheus/prometheus/git/refs{/sha}","trees_url":"https://api.github.com/repos/prometheus/prometheus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prometheus/prometheus/statuses/{sha}","languages_url":"https://api.github.com/repos/prometheus/prometheus/languages","stargazers_url":"https://api.github.com/repos/prometheus/prometheus/stargazers","contributors_url":"https://api.github.com/repos/prometheus/prometheus/contributors","subscribers_url":"https://api.github.com/repos/prometheus/prometheus/subscribers","subscription_url":"https://api.github.com/repos/prometheus/prometheus/subscription","commits_url":"https://api.github.com/repos/prometheus/prometheus/commits{/sha}","git_commits_url":"https://api.github.com/repos/prometheus/prometheus/git/commits{/sha}","comments_url":"https://api.github.com/repos/prometheus/prometheus/comments{/number}","issue_comment_url":"https://api.github.com/repos/prometheus/prometheus/issues/comments{/number}","contents_url":"https://api.github.com/repos/prometheus/prometheus/contents/{+path}","compare_url":"https://api.github.com/repos/prometheus/prometheus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prometheus/prometheus/merges","archive_url":"https://api.github.com/repos/prometheus/prometheus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prometheus/prometheus/downloads","issues_url":"https://api.github.com/repos/prometheus/prometheus/issues{/number}","pulls_url":"https://api.github.com/repos/prometheus/prometheus/pulls{/number}","milestones_url":"https://api.github.com/repos/prometheus/prometheus/milestones{/number}","notifications_url":"https://api.github.com/repos/prometheus/prometheus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prometheus/prometheus/labels{/name}","releases_url":"https://api.github.com/repos/prometheus/prometheus/releases{/id}","created_at":"2012-11-24T11:14:12Z","updated_at":"2015-06-16T13:10:51Z","pushed_at":"2015-06-16T13:29:27Z","git_url":"git://github.com/prometheus/prometheus.git","ssh_url":"git@github.com:prometheus/prometheus.git","clone_url":"https://github.com/prometheus/prometheus.git","svn_url":"https://github.com/prometheus/prometheus","homepage":"http://prometheus.io/","size":19081,"stargazers_count":2310,"watchers_count":2310,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":133,"mirror_url":null,"open_issues_count":81,"forks":133,"open_issues":81,"watchers":2310,"default_branch":"master"}},"base":{"label":"prometheus:master","ref":"master","sha":"95bd64c770b34171905059ba28a87a63c4efa424","user":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"repo":{"id":6838921,"name":"prometheus","full_name":"prometheus/prometheus","owner":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prometheus/prometheus","description":"The Prometheus monitoring system and time series database.","fork":false,"url":"https://api.github.com/repos/prometheus/prometheus","forks_url":"https://api.github.com/repos/prometheus/prometheus/forks","keys_url":"https://api.github.com/repos/prometheus/prometheus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prometheus/prometheus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prometheus/prometheus/teams","hooks_url":"https://api.github.com/repos/prometheus/prometheus/hooks","issue_events_url":"https://api.github.com/repos/prometheus/prometheus/issues/events{/number}","events_url":"https://api.github.com/repos/prometheus/prometheus/events","assignees_url":"https://api.github.com/repos/prometheus/prometheus/assignees{/user}","branches_url":"https://api.github.com/repos/prometheus/prometheus/branches{/branch}","tags_url":"https://api.github.com/repos/prometheus/prometheus/tags","blobs_url":"https://api.github.com/repos/prometheus/prometheus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prometheus/prometheus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prometheus/prometheus/git/refs{/sha}","trees_url":"https://api.github.com/repos/prometheus/prometheus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prometheus/prometheus/statuses/{sha}","languages_url":"https://api.github.com/repos/prometheus/prometheus/languages","stargazers_url":"https://api.github.com/repos/prometheus/prometheus/stargazers","contributors_url":"https://api.github.com/repos/prometheus/prometheus/contributors","subscribers_url":"https://api.github.com/repos/prometheus/prometheus/subscribers","subscription_url":"https://api.github.com/repos/prometheus/prometheus/subscription","commits_url":"https://api.github.com/repos/prometheus/prometheus/commits{/sha}","git_commits_url":"https://api.github.com/repos/prometheus/prometheus/git/commits{/sha}","comments_url":"https://api.github.com/repos/prometheus/prometheus/comments{/number}","issue_comment_url":"https://api.github.com/repos/prometheus/prometheus/issues/comments{/number}","contents_url":"https://api.github.com/repos/prometheus/prometheus/contents/{+path}","compare_url":"https://api.github.com/repos/prometheus/prometheus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prometheus/prometheus/merges","archive_url":"https://api.github.com/repos/prometheus/prometheus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prometheus/prometheus/downloads","issues_url":"https://api.github.com/repos/prometheus/prometheus/issues{/number}","pulls_url":"https://api.github.com/repos/prometheus/prometheus/pulls{/number}","milestones_url":"https://api.github.com/repos/prometheus/prometheus/milestones{/number}","notifications_url":"https://api.github.com/repos/prometheus/prometheus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prometheus/prometheus/labels{/name}","releases_url":"https://api.github.com/repos/prometheus/prometheus/releases{/id}","created_at":"2012-11-24T11:14:12Z","updated_at":"2015-06-16T13:10:51Z","pushed_at":"2015-06-16T13:29:27Z","git_url":"git://github.com/prometheus/prometheus.git","ssh_url":"git@github.com:prometheus/prometheus.git","clone_url":"https://github.com/prometheus/prometheus.git","svn_url":"https://github.com/prometheus/prometheus","homepage":"http://prometheus.io/","size":19081,"stargazers_count":2310,"watchers_count":2310,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":133,"mirror_url":null,"open_issues_count":81,"forks":133,"open_issues":81,"watchers":2310,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prometheus/prometheus/pulls/810"},"html":{"href":"https://github.com/prometheus/prometheus/pull/810"},"issue":{"href":"https://api.github.com/repos/prometheus/prometheus/issues/810"},"comments":{"href":"https://api.github.com/repos/prometheus/prometheus/issues/810/comments"},"review_comments":{"href":"https://api.github.com/repos/prometheus/prometheus/pulls/810/comments"},"review_comment":{"href":"https://api.github.com/repos/prometheus/prometheus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prometheus/prometheus/pulls/810/commits"},"statuses":{"href":"https://api.github.com/repos/prometheus/prometheus/statuses/5de5baa2843e2d9f845ce54b8e4dc0134656f491"}}}}