-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
@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 |
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? |
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 |
SDK resolvers can get and set the
State
property on theSdkResolverContext
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