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

Fine tuning of what types of project update affect what state #11213

Merged
merged 2 commits into from
Nov 14, 2024

Conversation

davidwengier
Copy link
Contributor

@davidwengier davidwengier commented Nov 14, 2024

Follow up to #11191 which caused RPS regressions.

There were some edge-y things I papered over in that PR, assuming they were unnecessary over-complications, but given the RPS regression I had a closer look, and they could have caused re-compilation of closed documents when only tag helpers changed, which would be new behaviour. Not entirely convinced the re-compilation is all unnecessary (if a document used a Tag Helper that has only just been discovered, then its code gen would legitimately change) but it's hard to justify when I can't point to any tooling for the closed files that would actually benefit from the extra work.

The key thing is not changing DocumentCollectionVersion when only ProjectWorkspaceState changes. Not re-calculating import documents was just a little extra amuse-bouche, and not caching the computed state tracker is pure paranoia.

@davidwengier davidwengier requested a review from a team as a code owner November 14, 2024 20:46
@davidwengier
Copy link
Contributor Author

Test insertion shows an improvement in the metric that previously regressed: https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/592392

Note that I think that means its an improvement against the original baseline, and not the regressed metric value, so I think this is not just avoiding a hit, but actually clawing some back. Though I couldn't actually saw how, so I might be wrong about that :)


// If the host project has changed then we need to recompute the imports map
var importsToRelatedDocuments = s_emptyImportsToRelatedDocuments;
var state = new ProjectState(this, numberOfDocumentsMayHaveChanged: !configUnchanged, hostProject, projectWorkspaceState, documents, importsToRelatedDocuments);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a bit hidden, so I'll call it out here. Where I said in the PR description that updating the DocumentCollectionVersion was the main issue, its this numberOfDocumentsMayHaveChanged parameter.

In my original PR I equated any project change to a possible document change, but tag helpers changing is definitely not that.

Copy link
Contributor

@ryzngard ryzngard left a comment

Choose a reason for hiding this comment

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

I think this makes sense overall 🤷

@@ -160,12 +160,14 @@ public virtual DocumentState WithImportsChange()
return state;
}

public virtual DocumentState WithProjectChange()
public virtual DocumentState WithProjectChange(bool cacheComputedState)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still not sure when or why this should be true or false. I see in the PR but not really the impact of it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll admit this isn't great, and I think the reasoning around what the computed state actually achieves, and whether its worth caching, is not fully understood by anyone. Or perhaps better said, I don't think I, or anyone else, could write a convincing comment explaining why this value should be true or false. I've made things match previous behaviour, and that seems to have had no bad outcomes, and I look forward to Dustin removing the computed state tracker in the future.

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.

3 participants