{"action":"created","comment":{"url":"https://api.github.com/repos/atom/autocomplete-plus/pulls/comments/39795231","id":39795231,"diff_hunk":"@@ -97,10 +97,11 @@ class Symbol\n \n     unless @type?\n       typePriority = 0\n-      for type, options of config\n+      for type in Object.keys(config)\n+        options = config[type]\n         continue unless options.selectors?\n         @metadataByPath.forEach ({scopeChains}) =>\n-          for scopeChain, __ of scopeChains\n+          for scopeChain in Object.keys(scopeChains)","path":"lib/symbol-store.coffee","position":10,"original_position":10,"commit_id":"11810d6bb4e25d42a70a921c3b70ea4aa393722e","original_commit_id":"11810d6bb4e25d42a70a921c3b70ea4aa393722e","user":{"login":"benogle","id":69169,"avatar_url":"https://avatars.githubusercontent.com/u/69169?v=3","gravatar_id":"","url":"https://api.github.com/users/benogle","html_url":"https://github.com/benogle","followers_url":"https://api.github.com/users/benogle/followers","following_url":"https://api.github.com/users/benogle/following{/other_user}","gists_url":"https://api.github.com/users/benogle/gists{/gist_id}","starred_url":"https://api.github.com/users/benogle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benogle/subscriptions","organizations_url":"https://api.github.com/users/benogle/orgs","repos_url":"https://api.github.com/users/benogle/repos","events_url":"https://api.github.com/users/benogle/events{/privacy}","received_events_url":"https://api.github.com/users/benogle/received_events","type":"User","site_admin":true},"body":"Does this produce a garbage array?","created_at":"2015-09-17T20:33:10Z","updated_at":"2015-09-17T20:33:10Z","html_url":"https://github.com/atom/autocomplete-plus/pull/575#discussion_r39795231","pull_request_url":"https://api.github.com/repos/atom/autocomplete-plus/pulls/575","_links":{"self":{"href":"https://api.github.com/repos/atom/autocomplete-plus/pulls/comments/39795231"},"html":{"href":"https://github.com/atom/autocomplete-plus/pull/575#discussion_r39795231"},"pull_request":{"href":"https://api.github.com/repos/atom/autocomplete-plus/pulls/575"}}},"pull_request":{"url":"https://api.github.com/repos/atom/autocomplete-plus/pulls/575","id":45337977,"html_url":"https://github.com/atom/autocomplete-plus/pull/575","diff_url":"https://github.com/atom/autocomplete-plus/pull/575.diff","patch_url":"https://github.com/atom/autocomplete-plus/pull/575.patch","issue_url":"https://api.github.com/repos/atom/autocomplete-plus/issues/575","number":575,"state":"open","locked":false,"title":"Cache and micro-optimize suggestion generation in SymbolProvider","user":{"login":"nathansobo","id":1789,"avatar_url":"https://avatars.githubusercontent.com/u/1789?v=3","gravatar_id":"","url":"https://api.github.com/users/nathansobo","html_url":"https://github.com/nathansobo","followers_url":"https://api.github.com/users/nathansobo/followers","following_url":"https://api.github.com/users/nathansobo/following{/other_user}","gists_url":"https://api.github.com/users/nathansobo/gists{/gist_id}","starred_url":"https://api.github.com/users/nathansobo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathansobo/subscriptions","organizations_url":"https://api.github.com/users/nathansobo/orgs","repos_url":"https://api.github.com/users/nathansobo/repos","events_url":"https://api.github.com/users/nathansobo/events{/privacy}","received_events_url":"https://api.github.com/users/nathansobo/received_events","type":"User","site_admin":true},"body":"When we have a large number of symbols in the symbol store due to a large file being opened and tokenized, computing suggestions gets expensive due to matching selectors in the symbols against the current scope in a tight loop. Long term, we need to compute the type of a symbol once upon insertion into the symbol store, but this PR caches the selector matches to at least minimize the work being performed in the loop on subsequent completions for the same scope.\r\n\r\nThis profile was performed by opening `text-editor-spec.coffee` and `huge.js` in an editor and allowing both to tokenize. Then I typed at the end of the file, typed in a string to bust the existing caching, then switched back to the end of the file and typed more. With the new caching, subsequent completions are about ~5x faster, from ~100ms to ~20ms. This could be even faster if we used a smarter approach to index these symbols, but this is a good start.\r\n\r\n### Before\r\n\r\n![screen shot 2015-09-17 at 2 24 02 pm](https://cloud.githubusercontent.com/assets/1789/9945078/6a6c1fe6-5d48-11e5-914c-31ee201a26f0.png)\r\n\r\n### After\r\n\r\n![screen shot 2015-09-17 at 2 23 38 pm](https://cloud.githubusercontent.com/assets/1789/9945084/73520e72-5d48-11e5-8aaa-267667d6fd46.png)\r\n\r\n/cc @benogle @maxbrunsfeld","created_at":"2015-09-17T20:29:59Z","updated_at":"2015-09-17T20:33:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0440063be6af6c249079550ceb080214439fe399","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/atom/autocomplete-plus/pulls/575/commits","review_comments_url":"https://api.github.com/repos/atom/autocomplete-plus/pulls/575/comments","review_comment_url":"https://api.github.com/repos/atom/autocomplete-plus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/atom/autocomplete-plus/issues/575/comments","statuses_url":"https://api.github.com/repos/atom/autocomplete-plus/statuses/11810d6bb4e25d42a70a921c3b70ea4aa393722e","head":{"label":"atom:ns-optimize-suggestions","ref":"ns-optimize-suggestions","sha":"11810d6bb4e25d42a70a921c3b70ea4aa393722e","user":{"login":"atom","id":1089146,"avatar_url":"https://avatars.githubusercontent.com/u/1089146?v=3","gravatar_id":"","url":"https://api.github.com/users/atom","html_url":"https://github.com/atom","followers_url":"https://api.github.com/users/atom/followers","following_url":"https://api.github.com/users/atom/following{/other_user}","gists_url":"https://api.github.com/users/atom/gists{/gist_id}","starred_url":"https://api.github.com/users/atom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atom/subscriptions","organizations_url":"https://api.github.com/users/atom/orgs","repos_url":"https://api.github.com/users/atom/repos","events_url":"https://api.github.com/users/atom/events{/privacy}","received_events_url":"https://api.github.com/users/atom/received_events","type":"Organization","site_admin":false},"repo":{"id":17254728,"name":"autocomplete-plus","full_name":"atom/autocomplete-plus","owner":{"login":"atom","id":1089146,"avatar_url":"https://avatars.githubusercontent.com/u/1089146?v=3","gravatar_id":"","url":"https://api.github.com/users/atom","html_url":"https://github.com/atom","followers_url":"https://api.github.com/users/atom/followers","following_url":"https://api.github.com/users/atom/following{/other_user}","gists_url":"https://api.github.com/users/atom/gists{/gist_id}","starred_url":"https://api.github.com/users/atom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atom/subscriptions","organizations_url":"https://api.github.com/users/atom/orgs","repos_url":"https://api.github.com/users/atom/repos","events_url":"https://api.github.com/users/atom/events{/privacy}","received_events_url":"https://api.github.com/users/atom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/atom/autocomplete-plus","description":"View and insert possible completions in the editor while typing","fork":false,"url":"https://api.github.com/repos/atom/autocomplete-plus","forks_url":"https://api.github.com/repos/atom/autocomplete-plus/forks","keys_url":"https://api.github.com/repos/atom/autocomplete-plus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/atom/autocomplete-plus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/atom/autocomplete-plus/teams","hooks_url":"https://api.github.com/repos/atom/autocomplete-plus/hooks","issue_events_url":"https://api.github.com/repos/atom/autocomplete-plus/issues/events{/number}","events_url":"https://api.github.com/repos/atom/autocomplete-plus/events","assignees_url":"https://api.github.com/repos/atom/autocomplete-plus/assignees{/user}","branches_url":"https://api.github.com/repos/atom/autocomplete-plus/branches{/branch}","tags_url":"https://api.github.com/repos/atom/autocomplete-plus/tags","blobs_url":"https://api.github.com/repos/atom/autocomplete-plus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/atom/autocomplete-plus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/atom/autocomplete-plus/git/refs{/sha}","trees_url":"https://api.github.com/repos/atom/autocomplete-plus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/atom/autocomplete-plus/statuses/{sha}","languages_url":"https://api.github.com/repos/atom/autocomplete-plus/languages","stargazers_url":"https://api.github.com/repos/atom/autocomplete-plus/stargazers","contributors_url":"https://api.github.com/repos/atom/autocomplete-plus/contributors","subscribers_url":"https://api.github.com/repos/atom/autocomplete-plus/subscribers","subscription_url":"https://api.github.com/repos/atom/autocomplete-plus/subscription","commits_url":"https://api.github.com/repos/atom/autocomplete-plus/commits{/sha}","git_commits_url":"https://api.github.com/repos/atom/autocomplete-plus/git/commits{/sha}","comments_url":"https://api.github.com/repos/atom/autocomplete-plus/comments{/number}","issue_comment_url":"https://api.github.com/repos/atom/autocomplete-plus/issues/comments{/number}","contents_url":"https://api.github.com/repos/atom/autocomplete-plus/contents/{+path}","compare_url":"https://api.github.com/repos/atom/autocomplete-plus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/atom/autocomplete-plus/merges","archive_url":"https://api.github.com/repos/atom/autocomplete-plus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/atom/autocomplete-plus/downloads","issues_url":"https://api.github.com/repos/atom/autocomplete-plus/issues{/number}","pulls_url":"https://api.github.com/repos/atom/autocomplete-plus/pulls{/number}","milestones_url":"https://api.github.com/repos/atom/autocomplete-plus/milestones{/number}","notifications_url":"https://api.github.com/repos/atom/autocomplete-plus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/atom/autocomplete-plus/labels{/name}","releases_url":"https://api.github.com/repos/atom/autocomplete-plus/releases{/id}","created_at":"2014-02-27T16:03:36Z","updated_at":"2015-09-17T08:56:28Z","pushed_at":"2015-09-17T20:29:59Z","git_url":"git://github.com/atom/autocomplete-plus.git","ssh_url":"git@github.com:atom/autocomplete-plus.git","clone_url":"https://github.com/atom/autocomplete-plus.git","svn_url":"https://github.com/atom/autocomplete-plus","homepage":"","size":4763,"stargazers_count":409,"watchers_count":409,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":116,"mirror_url":null,"open_issues_count":46,"forks":116,"open_issues":46,"watchers":409,"default_branch":"master"}},"base":{"label":"atom:master","ref":"master","sha":"e1b63e85298a2fac8913a535978a919e9c215267","user":{"login":"atom","id":1089146,"avatar_url":"https://avatars.githubusercontent.com/u/1089146?v=3","gravatar_id":"","url":"https://api.github.com/users/atom","html_url":"https://github.com/atom","followers_url":"https://api.github.com/users/atom/followers","following_url":"https://api.github.com/users/atom/following{/other_user}","gists_url":"https://api.github.com/users/atom/gists{/gist_id}","starred_url":"https://api.github.com/users/atom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atom/subscriptions","organizations_url":"https://api.github.com/users/atom/orgs","repos_url":"https://api.github.com/users/atom/repos","events_url":"https://api.github.com/users/atom/events{/privacy}","received_events_url":"https://api.github.com/users/atom/received_events","type":"Organization","site_admin":false},"repo":{"id":17254728,"name":"autocomplete-plus","full_name":"atom/autocomplete-plus","owner":{"login":"atom","id":1089146,"avatar_url":"https://avatars.githubusercontent.com/u/1089146?v=3","gravatar_id":"","url":"https://api.github.com/users/atom","html_url":"https://github.com/atom","followers_url":"https://api.github.com/users/atom/followers","following_url":"https://api.github.com/users/atom/following{/other_user}","gists_url":"https://api.github.com/users/atom/gists{/gist_id}","starred_url":"https://api.github.com/users/atom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atom/subscriptions","organizations_url":"https://api.github.com/users/atom/orgs","repos_url":"https://api.github.com/users/atom/repos","events_url":"https://api.github.com/users/atom/events{/privacy}","received_events_url":"https://api.github.com/users/atom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/atom/autocomplete-plus","description":"View and insert possible completions in the editor while typing","fork":false,"url":"https://api.github.com/repos/atom/autocomplete-plus","forks_url":"https://api.github.com/repos/atom/autocomplete-plus/forks","keys_url":"https://api.github.com/repos/atom/autocomplete-plus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/atom/autocomplete-plus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/atom/autocomplete-plus/teams","hooks_url":"https://api.github.com/repos/atom/autocomplete-plus/hooks","issue_events_url":"https://api.github.com/repos/atom/autocomplete-plus/issues/events{/number}","events_url":"https://api.github.com/repos/atom/autocomplete-plus/events","assignees_url":"https://api.github.com/repos/atom/autocomplete-plus/assignees{/user}","branches_url":"https://api.github.com/repos/atom/autocomplete-plus/branches{/branch}","tags_url":"https://api.github.com/repos/atom/autocomplete-plus/tags","blobs_url":"https://api.github.com/repos/atom/autocomplete-plus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/atom/autocomplete-plus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/atom/autocomplete-plus/git/refs{/sha}","trees_url":"https://api.github.com/repos/atom/autocomplete-plus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/atom/autocomplete-plus/statuses/{sha}","languages_url":"https://api.github.com/repos/atom/autocomplete-plus/languages","stargazers_url":"https://api.github.com/repos/atom/autocomplete-plus/stargazers","contributors_url":"https://api.github.com/repos/atom/autocomplete-plus/contributors","subscribers_url":"https://api.github.com/repos/atom/autocomplete-plus/subscribers","subscription_url":"https://api.github.com/repos/atom/autocomplete-plus/subscription","commits_url":"https://api.github.com/repos/atom/autocomplete-plus/commits{/sha}","git_commits_url":"https://api.github.com/repos/atom/autocomplete-plus/git/commits{/sha}","comments_url":"https://api.github.com/repos/atom/autocomplete-plus/comments{/number}","issue_comment_url":"https://api.github.com/repos/atom/autocomplete-plus/issues/comments{/number}","contents_url":"https://api.github.com/repos/atom/autocomplete-plus/contents/{+path}","compare_url":"https://api.github.com/repos/atom/autocomplete-plus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/atom/autocomplete-plus/merges","archive_url":"https://api.github.com/repos/atom/autocomplete-plus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/atom/autocomplete-plus/downloads","issues_url":"https://api.github.com/repos/atom/autocomplete-plus/issues{/number}","pulls_url":"https://api.github.com/repos/atom/autocomplete-plus/pulls{/number}","milestones_url":"https://api.github.com/repos/atom/autocomplete-plus/milestones{/number}","notifications_url":"https://api.github.com/repos/atom/autocomplete-plus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/atom/autocomplete-plus/labels{/name}","releases_url":"https://api.github.com/repos/atom/autocomplete-plus/releases{/id}","created_at":"2014-02-27T16:03:36Z","updated_at":"2015-09-17T08:56:28Z","pushed_at":"2015-09-17T20:29:59Z","git_url":"git://github.com/atom/autocomplete-plus.git","ssh_url":"git@github.com:atom/autocomplete-plus.git","clone_url":"https://github.com/atom/autocomplete-plus.git","svn_url":"https://github.com/atom/autocomplete-plus","homepage":"","size":4763,"stargazers_count":409,"watchers_count":409,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":116,"mirror_url":null,"open_issues_count":46,"forks":116,"open_issues":46,"watchers":409,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/atom/autocomplete-plus/pulls/575"},"html":{"href":"https://github.com/atom/autocomplete-plus/pull/575"},"issue":{"href":"https://api.github.com/repos/atom/autocomplete-plus/issues/575"},"comments":{"href":"https://api.github.com/repos/atom/autocomplete-plus/issues/575/comments"},"review_comments":{"href":"https://api.github.com/repos/atom/autocomplete-plus/pulls/575/comments"},"review_comment":{"href":"https://api.github.com/repos/atom/autocomplete-plus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/atom/autocomplete-plus/pulls/575/commits"},"statuses":{"href":"https://api.github.com/repos/atom/autocomplete-plus/statuses/11810d6bb4e25d42a70a921c3b70ea4aa393722e"}}}}