{"action":"created","comment":{"url":"https://api.github.com/repos/matrix-org/synapse/pulls/comments/36843487","id":36843487,"diff_hunk":"@@ -401,10 +410,14 @@ def handle_room(event):\n             except:\n                 logger.exception(\"Failed to get snapshot\")\n \n-        yield defer.gatherResults(\n-            [handle_room(e) for e in room_list],\n-            consumeErrors=True\n-        ).addErrback(unwrapFirstError)\n+        # Only do N rooms at once\n+        n = 5\n+        d_list = [handle_room(e) for e in room_list]\n+        for ds in [d_list[i:i + n] for i in range(0, len(d_list), n)]:\n+            yield defer.gatherResults(\n+                ds,\n+                consumeErrors=True\n+            ).addErrback(unwrapFirstError)","path":"synapse/handlers/message.py","position":54,"original_position":54,"commit_id":"d7451e0f22020624463d3c5f24a2fe54ed451b59","original_commit_id":"d7451e0f22020624463d3c5f24a2fe54ed451b59","user":{"login":"NegativeMjark","id":904009,"avatar_url":"https://avatars.githubusercontent.com/u/904009?v=3","gravatar_id":"","url":"https://api.github.com/users/NegativeMjark","html_url":"https://github.com/NegativeMjark","followers_url":"https://api.github.com/users/NegativeMjark/followers","following_url":"https://api.github.com/users/NegativeMjark/following{/other_user}","gists_url":"https://api.github.com/users/NegativeMjark/gists{/gist_id}","starred_url":"https://api.github.com/users/NegativeMjark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NegativeMjark/subscriptions","organizations_url":"https://api.github.com/users/NegativeMjark/orgs","repos_url":"https://api.github.com/users/NegativeMjark/repos","events_url":"https://api.github.com/users/NegativeMjark/events{/privacy}","received_events_url":"https://api.github.com/users/NegativeMjark/received_events","type":"User","site_admin":false},"body":"It would probably be clearer to do:\r\n\r\n    for i in range(0, len(d_list), n):\r\n      ds = d_list[i:i + n]","created_at":"2015-08-12T10:02:35Z","updated_at":"2015-08-12T10:02:35Z","html_url":"https://github.com/matrix-org/synapse/pull/219#discussion_r36843487","pull_request_url":"https://api.github.com/repos/matrix-org/synapse/pulls/219","_links":{"self":{"href":"https://api.github.com/repos/matrix-org/synapse/pulls/comments/36843487"},"html":{"href":"https://github.com/matrix-org/synapse/pull/219#discussion_r36843487"},"pull_request":{"href":"https://api.github.com/repos/matrix-org/synapse/pulls/219"}}},"pull_request":{"url":"https://api.github.com/repos/matrix-org/synapse/pulls/219","id":42221209,"html_url":"https://github.com/matrix-org/synapse/pull/219","diff_url":"https://github.com/matrix-org/synapse/pull/219.diff","patch_url":"https://github.com/matrix-org/synapse/pull/219.patch","issue_url":"https://api.github.com/repos/matrix-org/synapse/issues/219","number":219,"state":"open","locked":false,"title":"Dictionary and list caches","user":{"login":"erikjohnston","id":8428120,"avatar_url":"https://avatars.githubusercontent.com/u/8428120?v=3","gravatar_id":"","url":"https://api.github.com/users/erikjohnston","html_url":"https://github.com/erikjohnston","followers_url":"https://api.github.com/users/erikjohnston/followers","following_url":"https://api.github.com/users/erikjohnston/following{/other_user}","gists_url":"https://api.github.com/users/erikjohnston/gists{/gist_id}","starred_url":"https://api.github.com/users/erikjohnston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erikjohnston/subscriptions","organizations_url":"https://api.github.com/users/erikjohnston/orgs","repos_url":"https://api.github.com/users/erikjohnston/repos","events_url":"https://api.github.com/users/erikjohnston/events{/privacy}","received_events_url":"https://api.github.com/users/erikjohnston/received_events","type":"User","site_admin":false},"body":"Adds:\r\n- `DictionaryCache`: Caches key -> dictionary lookups, supporting caching partial dicts, i.e. fetching a subset of dictionary keys for a particular key.\r\n- `CacheListDescriptor`: Wraps an existing cache to support bulk fetching of keys.\r\n\r\nChanges:\r\n- Make fetching of state groups use DictionaryCache.\r\n- Implement cached bulk fetching of `event_id` -> `state_group` using CacheListDescriptor\r\n- Adds cache of `get_recent_events_for_room`\r\n\r\nThis should significantly increase performance w.r.t. to the ACL filtering, as well as potentially other operations.\r\n","created_at":"2015-08-12T09:42:08Z","updated_at":"2015-08-12T10:02:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b0e084e4948f882f79790e46ab4a832db7ba140d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/matrix-org/synapse/pulls/219/commits","review_comments_url":"https://api.github.com/repos/matrix-org/synapse/pulls/219/comments","review_comment_url":"https://api.github.com/repos/matrix-org/synapse/pulls/comments{/number}","comments_url":"https://api.github.com/repos/matrix-org/synapse/issues/219/comments","statuses_url":"https://api.github.com/repos/matrix-org/synapse/statuses/d7451e0f22020624463d3c5f24a2fe54ed451b59","head":{"label":"matrix-org:erikj/dictionary_cache","ref":"erikj/dictionary_cache","sha":"d7451e0f22020624463d3c5f24a2fe54ed451b59","user":{"login":"matrix-org","id":8418310,"avatar_url":"https://avatars.githubusercontent.com/u/8418310?v=3","gravatar_id":"","url":"https://api.github.com/users/matrix-org","html_url":"https://github.com/matrix-org","followers_url":"https://api.github.com/users/matrix-org/followers","following_url":"https://api.github.com/users/matrix-org/following{/other_user}","gists_url":"https://api.github.com/users/matrix-org/gists{/gist_id}","starred_url":"https://api.github.com/users/matrix-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrix-org/subscriptions","organizations_url":"https://api.github.com/users/matrix-org/orgs","repos_url":"https://api.github.com/users/matrix-org/repos","events_url":"https://api.github.com/users/matrix-org/events{/privacy}","received_events_url":"https://api.github.com/users/matrix-org/received_events","type":"Organization","site_admin":false},"repo":{"id":22844864,"name":"synapse","full_name":"matrix-org/synapse","owner":{"login":"matrix-org","id":8418310,"avatar_url":"https://avatars.githubusercontent.com/u/8418310?v=3","gravatar_id":"","url":"https://api.github.com/users/matrix-org","html_url":"https://github.com/matrix-org","followers_url":"https://api.github.com/users/matrix-org/followers","following_url":"https://api.github.com/users/matrix-org/following{/other_user}","gists_url":"https://api.github.com/users/matrix-org/gists{/gist_id}","starred_url":"https://api.github.com/users/matrix-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrix-org/subscriptions","organizations_url":"https://api.github.com/users/matrix-org/orgs","repos_url":"https://api.github.com/users/matrix-org/repos","events_url":"https://api.github.com/users/matrix-org/events{/privacy}","received_events_url":"https://api.github.com/users/matrix-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/matrix-org/synapse","description":"Synapse: Matrix reference homeserver","fork":false,"url":"https://api.github.com/repos/matrix-org/synapse","forks_url":"https://api.github.com/repos/matrix-org/synapse/forks","keys_url":"https://api.github.com/repos/matrix-org/synapse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matrix-org/synapse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matrix-org/synapse/teams","hooks_url":"https://api.github.com/repos/matrix-org/synapse/hooks","issue_events_url":"https://api.github.com/repos/matrix-org/synapse/issues/events{/number}","events_url":"https://api.github.com/repos/matrix-org/synapse/events","assignees_url":"https://api.github.com/repos/matrix-org/synapse/assignees{/user}","branches_url":"https://api.github.com/repos/matrix-org/synapse/branches{/branch}","tags_url":"https://api.github.com/repos/matrix-org/synapse/tags","blobs_url":"https://api.github.com/repos/matrix-org/synapse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matrix-org/synapse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matrix-org/synapse/git/refs{/sha}","trees_url":"https://api.github.com/repos/matrix-org/synapse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matrix-org/synapse/statuses/{sha}","languages_url":"https://api.github.com/repos/matrix-org/synapse/languages","stargazers_url":"https://api.github.com/repos/matrix-org/synapse/stargazers","contributors_url":"https://api.github.com/repos/matrix-org/synapse/contributors","subscribers_url":"https://api.github.com/repos/matrix-org/synapse/subscribers","subscription_url":"https://api.github.com/repos/matrix-org/synapse/subscription","commits_url":"https://api.github.com/repos/matrix-org/synapse/commits{/sha}","git_commits_url":"https://api.github.com/repos/matrix-org/synapse/git/commits{/sha}","comments_url":"https://api.github.com/repos/matrix-org/synapse/comments{/number}","issue_comment_url":"https://api.github.com/repos/matrix-org/synapse/issues/comments{/number}","contents_url":"https://api.github.com/repos/matrix-org/synapse/contents/{+path}","compare_url":"https://api.github.com/repos/matrix-org/synapse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matrix-org/synapse/merges","archive_url":"https://api.github.com/repos/matrix-org/synapse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matrix-org/synapse/downloads","issues_url":"https://api.github.com/repos/matrix-org/synapse/issues{/number}","pulls_url":"https://api.github.com/repos/matrix-org/synapse/pulls{/number}","milestones_url":"https://api.github.com/repos/matrix-org/synapse/milestones{/number}","notifications_url":"https://api.github.com/repos/matrix-org/synapse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matrix-org/synapse/labels{/name}","releases_url":"https://api.github.com/repos/matrix-org/synapse/releases{/id}","created_at":"2014-08-11T15:51:42Z","updated_at":"2015-08-10T18:11:55Z","pushed_at":"2015-08-12T09:56:11Z","git_url":"git://github.com/matrix-org/synapse.git","ssh_url":"git@github.com:matrix-org/synapse.git","clone_url":"https://github.com/matrix-org/synapse.git","svn_url":"https://github.com/matrix-org/synapse","homepage":"http://matrix.org","size":15333,"stargazers_count":446,"watchers_count":446,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":39,"mirror_url":null,"open_issues_count":7,"forks":39,"open_issues":7,"watchers":446,"default_branch":"master"}},"base":{"label":"matrix-org:develop","ref":"develop","sha":"275f7c987c1f61a77802d1ffdc40ff2a4a1f3365","user":{"login":"matrix-org","id":8418310,"avatar_url":"https://avatars.githubusercontent.com/u/8418310?v=3","gravatar_id":"","url":"https://api.github.com/users/matrix-org","html_url":"https://github.com/matrix-org","followers_url":"https://api.github.com/users/matrix-org/followers","following_url":"https://api.github.com/users/matrix-org/following{/other_user}","gists_url":"https://api.github.com/users/matrix-org/gists{/gist_id}","starred_url":"https://api.github.com/users/matrix-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrix-org/subscriptions","organizations_url":"https://api.github.com/users/matrix-org/orgs","repos_url":"https://api.github.com/users/matrix-org/repos","events_url":"https://api.github.com/users/matrix-org/events{/privacy}","received_events_url":"https://api.github.com/users/matrix-org/received_events","type":"Organization","site_admin":false},"repo":{"id":22844864,"name":"synapse","full_name":"matrix-org/synapse","owner":{"login":"matrix-org","id":8418310,"avatar_url":"https://avatars.githubusercontent.com/u/8418310?v=3","gravatar_id":"","url":"https://api.github.com/users/matrix-org","html_url":"https://github.com/matrix-org","followers_url":"https://api.github.com/users/matrix-org/followers","following_url":"https://api.github.com/users/matrix-org/following{/other_user}","gists_url":"https://api.github.com/users/matrix-org/gists{/gist_id}","starred_url":"https://api.github.com/users/matrix-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrix-org/subscriptions","organizations_url":"https://api.github.com/users/matrix-org/orgs","repos_url":"https://api.github.com/users/matrix-org/repos","events_url":"https://api.github.com/users/matrix-org/events{/privacy}","received_events_url":"https://api.github.com/users/matrix-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/matrix-org/synapse","description":"Synapse: Matrix reference homeserver","fork":false,"url":"https://api.github.com/repos/matrix-org/synapse","forks_url":"https://api.github.com/repos/matrix-org/synapse/forks","keys_url":"https://api.github.com/repos/matrix-org/synapse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matrix-org/synapse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matrix-org/synapse/teams","hooks_url":"https://api.github.com/repos/matrix-org/synapse/hooks","issue_events_url":"https://api.github.com/repos/matrix-org/synapse/issues/events{/number}","events_url":"https://api.github.com/repos/matrix-org/synapse/events","assignees_url":"https://api.github.com/repos/matrix-org/synapse/assignees{/user}","branches_url":"https://api.github.com/repos/matrix-org/synapse/branches{/branch}","tags_url":"https://api.github.com/repos/matrix-org/synapse/tags","blobs_url":"https://api.github.com/repos/matrix-org/synapse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matrix-org/synapse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matrix-org/synapse/git/refs{/sha}","trees_url":"https://api.github.com/repos/matrix-org/synapse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matrix-org/synapse/statuses/{sha}","languages_url":"https://api.github.com/repos/matrix-org/synapse/languages","stargazers_url":"https://api.github.com/repos/matrix-org/synapse/stargazers","contributors_url":"https://api.github.com/repos/matrix-org/synapse/contributors","subscribers_url":"https://api.github.com/repos/matrix-org/synapse/subscribers","subscription_url":"https://api.github.com/repos/matrix-org/synapse/subscription","commits_url":"https://api.github.com/repos/matrix-org/synapse/commits{/sha}","git_commits_url":"https://api.github.com/repos/matrix-org/synapse/git/commits{/sha}","comments_url":"https://api.github.com/repos/matrix-org/synapse/comments{/number}","issue_comment_url":"https://api.github.com/repos/matrix-org/synapse/issues/comments{/number}","contents_url":"https://api.github.com/repos/matrix-org/synapse/contents/{+path}","compare_url":"https://api.github.com/repos/matrix-org/synapse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matrix-org/synapse/merges","archive_url":"https://api.github.com/repos/matrix-org/synapse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matrix-org/synapse/downloads","issues_url":"https://api.github.com/repos/matrix-org/synapse/issues{/number}","pulls_url":"https://api.github.com/repos/matrix-org/synapse/pulls{/number}","milestones_url":"https://api.github.com/repos/matrix-org/synapse/milestones{/number}","notifications_url":"https://api.github.com/repos/matrix-org/synapse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matrix-org/synapse/labels{/name}","releases_url":"https://api.github.com/repos/matrix-org/synapse/releases{/id}","created_at":"2014-08-11T15:51:42Z","updated_at":"2015-08-10T18:11:55Z","pushed_at":"2015-08-12T09:56:11Z","git_url":"git://github.com/matrix-org/synapse.git","ssh_url":"git@github.com:matrix-org/synapse.git","clone_url":"https://github.com/matrix-org/synapse.git","svn_url":"https://github.com/matrix-org/synapse","homepage":"http://matrix.org","size":15333,"stargazers_count":446,"watchers_count":446,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":39,"mirror_url":null,"open_issues_count":7,"forks":39,"open_issues":7,"watchers":446,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/matrix-org/synapse/pulls/219"},"html":{"href":"https://github.com/matrix-org/synapse/pull/219"},"issue":{"href":"https://api.github.com/repos/matrix-org/synapse/issues/219"},"comments":{"href":"https://api.github.com/repos/matrix-org/synapse/issues/219/comments"},"review_comments":{"href":"https://api.github.com/repos/matrix-org/synapse/pulls/219/comments"},"review_comment":{"href":"https://api.github.com/repos/matrix-org/synapse/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/matrix-org/synapse/pulls/219/commits"},"statuses":{"href":"https://api.github.com/repos/matrix-org/synapse/statuses/d7451e0f22020624463d3c5f24a2fe54ed451b59"}}}}