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

RAR as a Service: Transfer and execution #5699

Closed
wants to merge 38 commits into from

Conversation

ostorc
Copy link
Contributor

@ostorc ostorc commented Sep 2, 2020

This PR closes #5556 and #5557.

When this PR is closed it will provide functionality to delegate work to RAR node (implemented by #5555).

In this PR I provide necessary functionality to delegate work of RAR task to RAR node.

I have added code mostly into src\Tasks\ResolveAssemblyReferences\:
Client
Contains all logic for client to construct connection and to delegate work.
Contract
DTOs and interface which client expects server to have.
Formatters
Custom written formatters, so we don't wait for them to be constructed dynamically, which adds extra cost to 1st request.
Server
Server side logic for handling connection
Services
Logic used during execution of RAR task. In future, there should be added caching layer, etc.

@ostorc ostorc added the WIP label Sep 2, 2020
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.

I think this works, but it's a bigger change than I'd expected.

@ostorc ostorc force-pushed the rarAsService/transfer branch from e40ebcf to 7f7d7c3 Compare September 10, 2020 16:18
@ostorc ostorc force-pushed the rarAsService/transfer branch from 7f7d7c3 to 40d1d51 Compare September 10, 2020 16:25
@ostorc
Copy link
Contributor Author

ostorc commented Sep 10, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@ladipro ladipro left a comment

Choose a reason for hiding this comment

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

Thank you, I've done a first pass over the changes and have left comments and questions inline. Overall:

  • Would it be appropriate to remove the WIP label from the PR now?
  • Can you add a good description explaining the code structure, which files were generated by which tool and so on?
  • Is this PR also making it possible to run tasks concurrently in the RAR service? The change introducing getRootedPath would suggest so.
  • What is the caching strategy? Do entries ever expire? What guarantees that when a dependent assembly changes, all relevant entries are invalidated?

src/Build/BackEnd/BuildManager/BuildManager.cs Outdated Show resolved Hide resolved
src/Framework/MSBuildEventSource.cs Outdated Show resolved Hide resolved
Comment on lines +55 to +58
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
Copy link
Member

Choose a reason for hiding this comment

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

Can you please explain why this change is needed? Where does the request to load Newtonsoft.Json version <12 come from?

Copy link
Member

Choose a reason for hiding this comment

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

I believe @ostorc mentioned in our PR reviews meeting this week that StreamJsonRPC relies on it, but he doesn't actually depend on the part of StreamJsonRPC that depends on Newtonsoft.Json, so we were wondering if we could make an exception in ngen'ing it so that we don't have to.

Copy link
Contributor Author

@ostorc ostorc Sep 22, 2020

Choose a reason for hiding this comment

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

In this PR microsoft/vs-streamjsonrpc#556 was the unnecessary load of Newtonsoft.Json removed, so when the version with this change is out, we will be able to remove this dangerous lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, that didn't solve the issue. Issue #5752 will solve that.

src/Shared/UnitTests/MockEngine.cs Outdated Show resolved Hide resolved
src/Tasks/Microsoft.Build.Tasks.csproj Outdated Show resolved Hide resolved
src/Tasks/Microsoft.Build.Tasks.csproj Outdated Show resolved Hide resolved
@ostorc ostorc removed the WIP label Sep 17, 2020
@ostorc ostorc changed the title [WIP] RAR as a Service: Transfer and execution RAR as a Service: Transfer and execution Sep 17, 2020
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.

I didn't really review the MessagePack code, but the rest looks reasonable to me. It would be nice to avoid some of the long repetitive sections, but I know that isn't always possible.

src/Build/BackEnd/BuildManager/BuildManager.cs Outdated Show resolved Hide resolved
src/Build/BackEnd/Node/RarNode.cs Outdated Show resolved Hide resolved
src/Framework/MSBuildEventSource.cs Show resolved Hide resolved
Comment on lines +55 to +58
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
Copy link
Member

Choose a reason for hiding this comment

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

I believe @ostorc mentioned in our PR reviews meeting this week that StreamJsonRPC relies on it, but he doesn't actually depend on the part of StreamJsonRPC that depends on Newtonsoft.Json, so we were wondering if we could make an exception in ngen'ing it so that we don't have to.

src/Tasks.UnitTests/AssemblyDependency/Miscellaneous.cs Outdated Show resolved Hide resolved
{
switch (key)
{
case 0:
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain why does this structure makes sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed it little, not it should be more understandable. I was adopting format from MessagePack code generators


private BuildEventArgsFormatter() { }

#region BuildWarningEventArgs
Copy link
Member

Choose a reason for hiding this comment

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

Having not used MessagePack before, I can't say that I really understand what you're doing here.

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 need this custom formatter, so I don't have to use dynamic one (which is slower on first request). The implementation follows how it is generated on runtime (with some minor tweaks).

Copy link
Member

Choose a reason for hiding this comment

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

Is there no way to specify a message in some format and autogenerate the serializer code at build time? That's what I expect from protobuf.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is, but unfortunately it doesn't support delegating of version of nuget packages to other files, so it not reallly useful right now.

ostorc and others added 2 commits September 21, 2020 19:06
Co-authored-by: Forgind <Forgind@users.noreply.github.com>
src/Framework/MSBuildEventSource.cs Show resolved Hide resolved
src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs Outdated Show resolved Hide resolved
Comment on lines +62 to +65
catch (ConnectionLostException e)
{
throw new InternalErrorException("Request failed", e);
}
Copy link
Member

Choose a reason for hiding this comment

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

Do you have a test to exercise this case?

Copy link
Contributor Author

@ostorc ostorc Sep 23, 2020

Choose a reason for hiding this comment

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

No not direct one. But if we run test in RARaaS mode we can check for example that in AssemblyFoldersFromConfigFileNotFoundTest


private BuildEventArgsFormatter() { }

#region BuildWarningEventArgs
Copy link
Member

Choose a reason for hiding this comment

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

Is there no way to specify a message in some format and autogenerate the serializer code at build time? That's what I expect from protobuf.


if (!(serverStream is NamedPipeServerStream pipeServerStream))
{
return serverStream;
Copy link
Member

Choose a reason for hiding this comment

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

Can you comment this please? I don't understand the reasoning for the early return.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is for testing purposes. In testing scenarios I want to pass streams which I have created. And normal streams doesn't support rest of the method, so for this reason I am making early exit.

src/Build/BackEnd/Node/RarNode.cs Outdated Show resolved Hide resolved
src/Build/BackEnd/Node/RarNode.cs Outdated Show resolved Hide resolved
@ostorc ostorc force-pushed the rarAsService/transfer branch from a3d2e74 to 0185da0 Compare September 23, 2020 20:12
{
shutdownException = e;
return NodeEngineShutdownReason.Error;
return NodeEngineShutdownReason.BuildComplete;
Copy link
Member

Choose a reason for hiding this comment

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

Why are we assuming the build was completed when catching an OperationCanceledException

using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Empty line

@ladipro
Copy link
Member

ladipro commented Jan 8, 2021

We'll submit a fresh set of PRs as we reboot the RAR service effort. We'll be looking at this PR and the reverted #5613 for inspiration but it can be closed now.

@ladipro ladipro closed this Jan 8, 2021
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.

[RAR as Service] Data transfer
5 participants