{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/24375890","id":24375890,"diff_hunk":"@@ -19,6 +19,14 @@ namespace Microsoft.CodeAnalysis.Completion.Providers\n {\n     internal abstract partial class AbstractSymbolCompletionProvider : AbstractCompletionProvider\n     {\n+        // PERF: Many CompletionProviders dervice AbstractSymbolCompletionProvider and therefore\n+        // compute identical contexts. This actually shows up on the 2-core typing test.\n+        // Cache the most recent document/position/computed SyntaxContext to reduce repeat computation.\n+        private static Document cachedDocument;\n+        private static int cachedPosition;\n+        private static AbstractSyntaxContext cachedContext;\n+        private static readonly object cacheGate = new object();","path":"src/Features/Core/Completion/Providers/AbstractSymbolCompletionProvider.cs","position":10,"original_position":10,"commit_id":"f5a72c6ffc7258df9823df3fe46466470ab94b65","original_commit_id":"53ed75099e511b8c14d3ce063f90c23079de6d5f","user":{"login":"dpoeschl","id":235241,"avatar_url":"https://avatars.githubusercontent.com/u/235241?v=3","gravatar_id":"","url":"https://api.github.com/users/dpoeschl","html_url":"https://github.com/dpoeschl","followers_url":"https://api.github.com/users/dpoeschl/followers","following_url":"https://api.github.com/users/dpoeschl/following{/other_user}","gists_url":"https://api.github.com/users/dpoeschl/gists{/gist_id}","starred_url":"https://api.github.com/users/dpoeschl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpoeschl/subscriptions","organizations_url":"https://api.github.com/users/dpoeschl/orgs","repos_url":"https://api.github.com/users/dpoeschl/repos","events_url":"https://api.github.com/users/dpoeschl/events{/privacy}","received_events_url":"https://api.github.com/users/dpoeschl/received_events","type":"User","site_admin":false},"body":"For linked files cases, you could grab the set of linked documents and keep around caches for each of them. If documents are processed that are in the current set of caches, then just keep using them. If a document is processed that's not in the current set of caches, then clear the cache and re-populate with the new set of documents linked to the requested one (etc.). This solves the \"but how many?\" problem posed in the description by using exactly how many will be required (but no more) instead of trying to guess an appropriate constant number.","created_at":"2015-02-09T23:21:55Z","updated_at":"2015-02-09T23:21:55Z","html_url":"https://github.com/dotnet/roslyn/pull/336#discussion_r24375890","pull_request_url":"https://api.github.com/repos/dotnet/roslyn/pulls/336","_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/24375890"},"html":{"href":"https://github.com/dotnet/roslyn/pull/336#discussion_r24375890"},"pull_request":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/336"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/336","id":28965922,"html_url":"https://github.com/dotnet/roslyn/pull/336","diff_url":"https://github.com/dotnet/roslyn/pull/336.diff","patch_url":"https://github.com/dotnet/roslyn/pull/336.patch","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/336","number":336,"state":"open","locked":false,"title":"Add a small cache of AbstractSyntaxContext","user":{"login":"rchande","id":3751401,"avatar_url":"https://avatars.githubusercontent.com/u/3751401?v=3","gravatar_id":"","url":"https://api.github.com/users/rchande","html_url":"https://github.com/rchande","followers_url":"https://api.github.com/users/rchande/followers","following_url":"https://api.github.com/users/rchande/following{/other_user}","gists_url":"https://api.github.com/users/rchande/gists{/gist_id}","starred_url":"https://api.github.com/users/rchande/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rchande/subscriptions","organizations_url":"https://api.github.com/users/rchande/orgs","repos_url":"https://api.github.com/users/rchande/repos","events_url":"https://api.github.com/users/rchande/events{/privacy}","received_events_url":"https://api.github.com/users/rchande/received_events","type":"User","site_admin":false},"body":"AbstractSymbolCompletionProvider computes a SyntaxContext and passes\r\nit around while computing CompletionItems. Many CompletionProviders\r\nderive AbstractSymbolCompletionProvider in order to share the logic for\r\nlinked files completion. This means that we'll repeatedly compute the\r\nsame SyntaxContext for a given Document and position. This shows up in\r\nthe 2-core typing tests. To avoid this, we'll simply cache the most\r\nrecent Document/position/SyntaxContext and use it if it matches the\r\ncurrent request.\r\n\r\nI'm not sure how to best address the linked files case--currently, each provider iterates over all of the files, which means the one-element cache will never contain the right Document for the next provider. I suppose to the cache could contain more elements, but how many?","created_at":"2015-02-09T23:11:43Z","updated_at":"2015-02-09T23:21:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3735aefc33cf14ad133eed4dd4753cda9b509406","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/roslyn/pulls/336/commits","review_comments_url":"https://api.github.com/repos/dotnet/roslyn/pulls/336/comments","review_comment_url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/{number}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/336/comments","statuses_url":"https://api.github.com/repos/dotnet/roslyn/statuses/f5a72c6ffc7258df9823df3fe46466470ab94b65","head":{"label":"rchande:ContextCaching","ref":"ContextCaching","sha":"f5a72c6ffc7258df9823df3fe46466470ab94b65","user":{"login":"rchande","id":3751401,"avatar_url":"https://avatars.githubusercontent.com/u/3751401?v=3","gravatar_id":"","url":"https://api.github.com/users/rchande","html_url":"https://github.com/rchande","followers_url":"https://api.github.com/users/rchande/followers","following_url":"https://api.github.com/users/rchande/following{/other_user}","gists_url":"https://api.github.com/users/rchande/gists{/gist_id}","starred_url":"https://api.github.com/users/rchande/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rchande/subscriptions","organizations_url":"https://api.github.com/users/rchande/orgs","repos_url":"https://api.github.com/users/rchande/repos","events_url":"https://api.github.com/users/rchande/events{/privacy}","received_events_url":"https://api.github.com/users/rchande/received_events","type":"User","site_admin":false},"repo":{"id":30547830,"name":"roslyn","full_name":"rchande/roslyn","owner":{"login":"rchande","id":3751401,"avatar_url":"https://avatars.githubusercontent.com/u/3751401?v=3","gravatar_id":"","url":"https://api.github.com/users/rchande","html_url":"https://github.com/rchande","followers_url":"https://api.github.com/users/rchande/followers","following_url":"https://api.github.com/users/rchande/following{/other_user}","gists_url":"https://api.github.com/users/rchande/gists{/gist_id}","starred_url":"https://api.github.com/users/rchande/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rchande/subscriptions","organizations_url":"https://api.github.com/users/rchande/orgs","repos_url":"https://api.github.com/users/rchande/repos","events_url":"https://api.github.com/users/rchande/events{/privacy}","received_events_url":"https://api.github.com/users/rchande/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rchande/roslyn","description":"The .NET Compiler Platform (\"Roslyn\") provides open-source C# and Visual Basic compilers with rich code analysis APIs.","fork":true,"url":"https://api.github.com/repos/rchande/roslyn","forks_url":"https://api.github.com/repos/rchande/roslyn/forks","keys_url":"https://api.github.com/repos/rchande/roslyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rchande/roslyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rchande/roslyn/teams","hooks_url":"https://api.github.com/repos/rchande/roslyn/hooks","issue_events_url":"https://api.github.com/repos/rchande/roslyn/issues/events{/number}","events_url":"https://api.github.com/repos/rchande/roslyn/events","assignees_url":"https://api.github.com/repos/rchande/roslyn/assignees{/user}","branches_url":"https://api.github.com/repos/rchande/roslyn/branches{/branch}","tags_url":"https://api.github.com/repos/rchande/roslyn/tags","blobs_url":"https://api.github.com/repos/rchande/roslyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rchande/roslyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rchande/roslyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/rchande/roslyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rchande/roslyn/statuses/{sha}","languages_url":"https://api.github.com/repos/rchande/roslyn/languages","stargazers_url":"https://api.github.com/repos/rchande/roslyn/stargazers","contributors_url":"https://api.github.com/repos/rchande/roslyn/contributors","subscribers_url":"https://api.github.com/repos/rchande/roslyn/subscribers","subscription_url":"https://api.github.com/repos/rchande/roslyn/subscription","commits_url":"https://api.github.com/repos/rchande/roslyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/rchande/roslyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/rchande/roslyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/rchande/roslyn/issues/comments/{number}","contents_url":"https://api.github.com/repos/rchande/roslyn/contents/{+path}","compare_url":"https://api.github.com/repos/rchande/roslyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rchande/roslyn/merges","archive_url":"https://api.github.com/repos/rchande/roslyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rchande/roslyn/downloads","issues_url":"https://api.github.com/repos/rchande/roslyn/issues{/number}","pulls_url":"https://api.github.com/repos/rchande/roslyn/pulls{/number}","milestones_url":"https://api.github.com/repos/rchande/roslyn/milestones{/number}","notifications_url":"https://api.github.com/repos/rchande/roslyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rchande/roslyn/labels{/name}","releases_url":"https://api.github.com/repos/rchande/roslyn/releases{/id}","created_at":"2015-02-09T17:16:21Z","updated_at":"2015-02-09T17:16:48Z","pushed_at":"2015-02-09T23:16:17Z","git_url":"git://github.com/rchande/roslyn.git","ssh_url":"git@github.com:rchande/roslyn.git","clone_url":"https://github.com/rchande/roslyn.git","svn_url":"https://github.com/rchande/roslyn","homepage":"","size":50574,"stargazers_count":0,"watchers_count":0,"language":"C#","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":"dotnet:master","ref":"master","sha":"4f147f5b559071e432e15ed9ba5836603be7182c","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":29078997,"name":"roslyn","full_name":"dotnet/roslyn","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/roslyn","description":"The .NET Compiler Platform (\"Roslyn\") provides open-source C# and Visual Basic compilers with rich code analysis APIs.","fork":false,"url":"https://api.github.com/repos/dotnet/roslyn","forks_url":"https://api.github.com/repos/dotnet/roslyn/forks","keys_url":"https://api.github.com/repos/dotnet/roslyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/roslyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/roslyn/teams","hooks_url":"https://api.github.com/repos/dotnet/roslyn/hooks","issue_events_url":"https://api.github.com/repos/dotnet/roslyn/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/roslyn/events","assignees_url":"https://api.github.com/repos/dotnet/roslyn/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/roslyn/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/roslyn/tags","blobs_url":"https://api.github.com/repos/dotnet/roslyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/roslyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/roslyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/roslyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/roslyn/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/roslyn/languages","stargazers_url":"https://api.github.com/repos/dotnet/roslyn/stargazers","contributors_url":"https://api.github.com/repos/dotnet/roslyn/contributors","subscribers_url":"https://api.github.com/repos/dotnet/roslyn/subscribers","subscription_url":"https://api.github.com/repos/dotnet/roslyn/subscription","commits_url":"https://api.github.com/repos/dotnet/roslyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/roslyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/roslyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/{number}","contents_url":"https://api.github.com/repos/dotnet/roslyn/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/roslyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/roslyn/merges","archive_url":"https://api.github.com/repos/dotnet/roslyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/roslyn/downloads","issues_url":"https://api.github.com/repos/dotnet/roslyn/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/roslyn/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/roslyn/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/roslyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/roslyn/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/roslyn/releases{/id}","created_at":"2015-01-11T02:39:03Z","updated_at":"2015-02-09T22:40:09Z","pushed_at":"2015-02-09T22:33:14Z","git_url":"git://github.com/dotnet/roslyn.git","ssh_url":"git@github.com:dotnet/roslyn.git","clone_url":"https://github.com/dotnet/roslyn.git","svn_url":"https://github.com/dotnet/roslyn","homepage":"","size":64405,"stargazers_count":1115,"watchers_count":1115,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":196,"mirror_url":null,"open_issues_count":255,"forks":196,"open_issues":255,"watchers":1115,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/336"},"html":{"href":"https://github.com/dotnet/roslyn/pull/336"},"issue":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/336"},"comments":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/336/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/336/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/336/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/roslyn/statuses/f5a72c6ffc7258df9823df3fe46466470ab94b65"}}}}