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

Add "cache add" functionality to project caching #8726

Merged
merged 25 commits into from Aug 29, 2023

Conversation

dfederm
Copy link
Contributor

@dfederm dfederm commented May 2, 2023

This change add "cache add" functionality to project caching.

Today project caching exposes a hook to plugins for "I'm about to build this thing, do you want to take over instead?" and that's it. This change adds a few more hooks which report file accesses and processes (via Detours) and also for when a project finishes building. This allows a plugin to collect the file accesses and add entries to the cache for future replayability.

I strongly recommend reviewing each commit as opposed to the whole PR as a whole. I (hopefully) broke it down into reasonably reviewable chunks.

CC @AndyGerlicher @DmitriyShepelev

@dfederm dfederm force-pushed the project-cache-vnext branch 2 times, most recently from f11de70 to 848ed11 Compare May 3, 2023 16:45
Copy link
Member

@Forgind Forgind left a comment

Choose a reason for hiding this comment

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

Partial review (next commit to review is c738443)

With your explanation from this morning, your code is easier to review than I would've expected—I appreciate it.

My primary concern is making sure you don't worsen the experience of building without this flag set, something I intend to look into properly after I've looked at the rest of the PR when I give it a more wholistic look.

src/Build/BackEnd/BuildManager/BuildParameters.cs Outdated Show resolved Hide resolved
NuGet.config Outdated Show resolved Hide resolved
src/MSBuild/Resources/Strings.resx Show resolved Hide resolved
Copy link
Member

@Forgind Forgind left a comment

Choose a reason for hiding this comment

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

Partial review (next commit to review is c738443)

With your explanation from this morning, your code is easier to review than I would've expected—I appreciate it.

My primary concern is making sure you don't worsen the experience of building without this flag set, something I intend to look into properly after I've looked at the rest of the PR when I give it a more wholistic look.

@dfederm dfederm force-pushed the project-cache-vnext branch 2 times, most recently from 1eb641f to 75e2ee4 Compare May 15, 2023 17:19
@rainersigwald rainersigwald self-requested a review May 15, 2023 19:39
Copy link
Member

@Forgind Forgind left a comment

Choose a reason for hiding this comment

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

Looks pretty good! I didn't see anything too concerning as I went through, but I haven't signed off yet because it's too big to absorb everything at once, and I haven't properly looked through all your comments.

Copy link
Member

@Forgind Forgind left a comment

Choose a reason for hiding this comment

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

Looks pretty good! I didn't see anything too concerning as I went through, but I haven't signed off yet because it's too big to absorb everything at once, and I haven't properly looked through all your comments.

@Forgind
Copy link
Member

Forgind commented May 15, 2023

Unrelated, but why is GitHub putting my comment above and below my inline comments? I don't think it's done that on other PRs.

@dfederm dfederm force-pushed the project-cache-vnext branch 2 times, most recently from 27765de to cc16787 Compare May 15, 2023 23:50
Copy link
Member

@JanKrivanek JanKrivanek left a comment

Choose a reason for hiding this comment

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

Mostly looks fine.
I have added couple minor comments. My main concerns currently:

  • The change feels that it deserves some additional tests
  • Public nuget feed added
  • Possibly avoidable locking in FileAccessManager
  • Is there a chance that the additional dependencies might be missing by VS after insrtion? I have very vague knowledge here - so not sure how to best verify this other then experimental insertion. But it'd be uncovered after merging this PR anyway - so not a big concern

@Forgind
Copy link
Member

Forgind commented May 30, 2023

Is there a chance that the additional dependencies might be missing by VS after insrtion? I have very vague knowledge here - so not sure how to best verify this other then experimental insertion. But it'd be uncovered after merging this PR anyway - so not a big concern

I think it's worth a serious look and an exp/ branch. A couple years ago, I added a reference to a new System package, and it prevented us from inserting until we reverted it a couple months later. That was Bad.

https://github.com/dotnet/msbuild/pull/8726/files#r1190408764

@dfederm
Copy link
Contributor Author

dfederm commented May 31, 2023

Is there a chance that the additional dependencies might be missing by VS after insrtion? I have very vague knowledge here - so not sure how to best verify this other then experimental insertion. But it'd be uncovered after merging this PR anyway - so not a big concern

I think it's worth a serious look and an exp/ branch. A couple years ago, I added a reference to a new System package, and it prevented us from inserting until we reverted it a couple months later. That was Bad.

https://github.com/dotnet/msbuild/pull/8726/files#r1190408764

I tried this but am hitting the same errors I see in the PR gate. I'll need help resolving those issues as I have not attempted to introduce new dependencies to MSBuild before.

@Forgind
Copy link
Member

Forgind commented Jun 15, 2023

I made an exp/ branch for this PR (at its current version). Build result here. It looks like we'll have to add BuildXL to the baseline package (list?) used by source build for this to get past the official build stage. Then we can check whether it passes RPS.

Anyone know how to do that?

@JanKrivanek
Copy link
Member

I made an exp/ branch for this PR (at its current version). Build result here. It looks like we'll have to add BuildXL to the baseline package (list?) used by source build for this to get past the official build stage. Then we can check whether it passes RPS.

Anyone know how to do that?

As for source build - they should be added to source-build-reference-packages - instructions
Then we need to make sure we reference appropriate version of source-build-reference-packages - that should happen automagicaly once the issues with #8893 get resolved, as I created darc subscribtion.
Those are basically analogous steps to what I'm going through with #8903.

As for adding the binaries to VS and then requesting and getting exception for RPS/DDRit - there I unfortunately have no experience

eng/SourceBuildPrebuiltBaseline.xml Outdated Show resolved Hide resolved
NuGet.config Show resolved Hide resolved
dfederm and others added 2 commits August 24, 2023 08:33
Instead of suppressing warnings, explicitly declare CLSCompliant(false).
Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

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

Overall looks good to me. I have a few small comments and a few larger themes:

  • How should we think about testing here? Is it possible to build a mock so that the MSBuild codepaths can be exercised in this repo? If not how can you let us know ASAP if we break your plugin?
  • I want an opt-in API to report actual reads from e.g. roslyn compiler server; is that extending this or a separate thing?
  • Can we get at least a sketch of docs for the functionality and plugin requirements?
    • one thing I really want is the timing stuff: there's the secret marker report thing, but how does that sync with the scheduler's knowledge of what nodes are doing? is there a race between _scheduler!.GetExecutingRequestByNode and the marker report?

src/MSBuild/Resources/Strings.resx Show resolved Hide resolved
src/Shared/INodePacket.cs Outdated Show resolved Hide resolved
src/Build/Resources/Strings.resx Outdated Show resolved Hide resolved
src/Framework/FileAccess/DesiredAccess.cs Show resolved Hide resolved
src/Build/BackEnd/BuildManager/BuildManager.cs Outdated Show resolved Hide resolved
@dfederm
Copy link
Contributor Author

dfederm commented Aug 24, 2023

I want an opt-in API to report actual reads from e.g. roslyn compiler server; is that extending this or a separate thing?

Yup, see EngineServices.ReportFileAccess. That's how a task would self-report its accesses.

@dfederm
Copy link
Contributor Author

dfederm commented Aug 24, 2023

Aggregating remaining unaddressed feedback up to this point so I don't forget it (I find GitHub threading a bit hard to track over multiple iterations):

  • Audit tests to ensure proper coverage
    • E2E tests would be really nice, although this might be out of scope for now
  • Improve docs to properly describe the state of the feature
  • Razor compiler server... figure out if we need to allow this to breakaway as well

Reviewers, please let me know if I missed any of your feedback

@dfederm
Copy link
Contributor Author

dfederm commented Aug 28, 2023

Spoke with @rainersigwald offline.

So that this PR can make the 17.8 deadline, we agreed to defer the UTs (and ideally e2e tests) and docs to a separate PR which I'm promising to deliver soon.

wrt Razor compiler server, I'm hesitant to allow it to break away since that would lose the detours information even when not running in server mode (rzc.exe is used for both scenarios). We will likely need to revisit this at some point though...

@rainersigwald rainersigwald merged commit 462a917 into dotnet:main Aug 29, 2023
8 checks passed
@dfederm dfederm deleted the project-cache-vnext branch August 29, 2023 18:33
This was referenced Aug 29, 2023
rainersigwald added a commit to rainersigwald/msbuild that referenced this pull request Aug 30, 2023
rainersigwald added a commit that referenced this pull request Aug 30, 2023
* Revert "Ship BuildXL assemblies in our VSIX and not our NuGet packages (#9185)"

This reverts commit 0974273.

* Revert "Merge pull request #8726 from dfederm/project-cache-vnext"

This reverts commit 462a917, reversing
changes made to 5958b59.
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.

None yet

6 participants