Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow SDK resolvers to preserve state #2849

Merged
merged 4 commits into from
Jan 9, 2018
Merged

Conversation

jeffkl
Copy link
Contributor

@jeffkl jeffkl commented Jan 9, 2018

SDK resolvers can get and set the State property on the SdkResolverContext they receive. This state is preserved for the same resolver during the same build submission. When there is no build submission, the state is not preserved. Resolvers will need to take account for these considerations.

This will allow the NuGet-based SDK resolver to only look for and parse global.json once per build.

Address item 2 in #2803

Copy link
Contributor

@AndyGerlicher AndyGerlicher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@@ -1664,6 +1664,9 @@ private void CheckSubmissionCompletenessAndRemove(BuildSubmission submission)

// Clear all cached SDKs for the submission
SdkResolverService.ClearCache(submission.SubmissionId);

// Clear SDK resolver cache for the submission
Copy link
Contributor

@cdmihai cdmihai Jan 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line (and its comment) seems very similar to the previous one. A code comment on why this is would be nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, and after I took a second look at it, I decided this call should be moved. I've also improved the comment

@jeffkl
Copy link
Contributor Author

jeffkl commented Jan 9, 2018

@nguerrera, this PR allows resolvers to maintain state for a particular build submission. I'll be using it in my NuGet-based SDK resolver so that global.json is only searched for and deserialized once per build. Do you have any feedback on this implementation?

@jeffkl jeffkl merged commit 5c28a15 into dotnet:master Jan 9, 2018
@jeffkl jeffkl deleted the resolverState branch January 9, 2018 21:29
@nguerrera
Copy link
Contributor

In yesterday's sync, @AndyGerlicher said VS will cache all SDK resolver results per build. But (without digging in to code) this suggests that I'll be called multiple times per build and it is up to me to use a state object for caching. Which is it? Basically, will we get a perf win without doing anything or do we need to go implement the caching using this state feature?

@jeffkl
Copy link
Contributor Author

jeffkl commented Jan 9, 2018

For each build and unique SDK name, all resolvers are called in order. Once an SDK has been resolved, no resolvers are called again for that SDK. If another SDK comes along that is not in the cache, then all SDK resolvers are called again.

The point of this "state" object is so that a resolver can discover something about the environment (like a path to global.json) only once. But it will still only be called one for each unique SDK. So if your entire project tree only references Microsoft.NET.Sdk, the resolver is only called once anyway.

@jeffkl jeffkl mentioned this pull request Jan 10, 2018
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants