Skip to content

Fix evaluation logging for multi-proc builds - #2748

Merged
AndyGerlicher merged 9 commits into
dotnet:masterfrom
panopticoncentral:eval
Jan 2, 2018
Merged

AndyGerlicher merged 9 commits into
dotnet:masterfrom
panopticoncentral:eval

Conversation

@panopticoncentral

Copy link
Copy Markdown

When working on a build log viewer, I noticed that there are two issues with evaluation log events in multi-proc builds:

  • Because the evaluation ID was a static on the evaluator, each node reused evaluation IDs, resulting in non-unique and overlapping evaluation IDs on events in the log.
  • The evaluation ID was not serialized for messages and so was getting lost when de-serialized in the central node.

I know there are a lot of considerations around this, so let me know if something looks wrong about what I've done.

cc: @KirillOsenkov

@KirillOsenkov

Copy link
Copy Markdown
Member

Great find! This explain this issue my users have been reporting:
KirillOsenkov/MSBuildStructuredLog#132

int submissionId = reader.ReadInt32();
int projectInstanceId = reader.ReadInt32();
buildEventContext = new BuildEventContext(submissionId, nodeId, projectInstanceId, projectContextId, targetId, taskId);
int evaluationId = reader.ReadInt32();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For back compat, you should bump up the format version number, and read the new value only when the format version is greater than or equal the new version value.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is binary serialization which looks like the version number is derived from the CLR version. It looks like I shouldn't mess with that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You're right. I had confused this with the binary logging serialization, but that one's not affected by this PR.

@cdmihai

cdmihai commented Nov 28, 2017

Copy link
Copy Markdown
Contributor

ProjectInstance.Initialize has some postconditions that an evaluation ID should have been assigned. Can you please add the equivalent for Project.Reevaluate as well?

@cdmihai

cdmihai commented Nov 28, 2017

Copy link
Copy Markdown
Contributor

Can you please add a test for the out of proc case? You can use this test as an example.

@panopticoncentral

Copy link
Copy Markdown
Author

@cdmihai I pushed changes, can you take a look?

var result = submission.Execute();

Assert.Equal(BuildResultCode.Success, result.OverallResult);
Assert.True(_logger.AllBuildEvents.OfType<ProjectEvaluationStartedEventArgs>().GroupBy(args => args.BuildEventContext.EvaluationId).All(g => g.Count() == 1));

@cdmihai cdmihai Dec 6, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You should also assert that there are exactly two groups, right? There should have been two evaluations, each with a different evaluations ID

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like this is failing on .net core. Can you please take a look? Ping me if you need another set of eyes on it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@cdmihai What is the best way to debug a CoreCLR test? I see how to build it but not sure the easiest way to get it under the debugger.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Nevermind, looked at the docs and figured it out. I think I've fixed the bug.

@panopticoncentral

Copy link
Copy Markdown
Author

@dotnet-bot test Windows_NT Build for CoreCLR please

@panopticoncentral

Copy link
Copy Markdown
Author

@cdmihai Looks like everything is green, what do you think?

var result = submission.Execute();

Assert.Equal(BuildResultCode.Success, result.OverallResult);
Assert.True(_logger.AllBuildEvents.OfType<ProjectEvaluationStartedEventArgs>().GroupBy(args => args.BuildEventContext.EvaluationId).All(g => g.Count() == 1));

@cdmihai cdmihai Dec 12, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you also assert there's two groups (to make sure that two IDs got produced)? Or better yet, instead of grouping, assert that there are exactly two evaluation ids, and they're different values.

@cdmihai cdmihai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, with a testing nit suggestion.

@AndyGerlicher

Copy link
Copy Markdown
Contributor

@dotnet-bot test Windows_NT Build for CoreCLR please

@AndyGerlicher

Copy link
Copy Markdown
Contributor

@panopticoncentral Added a merge commit, hopefully it's correct?

@panopticoncentral

Copy link
Copy Markdown
Author

👍

@AndyGerlicher
AndyGerlicher merged commit 2567cc4 into dotnet:master Jan 2, 2018
@panopticoncentral

Copy link
Copy Markdown
Author

Thanks!

AndyGerlicher pushed a commit to cdmihai/msbuild that referenced this pull request Jan 24, 2018
CPS expects Project.LastEvaluationId to reflect the id of the ongoing, not yet finished evaluation.
This invariant regressed in dotnet#2748

LoggingService now creates an evaluation build event context separate from sending project started events. This allows the Evaluator to set the evaluation Id on Project before the first evaluation event gets fired.
AndyGerlicher pushed a commit that referenced this pull request Jan 24, 2018
CPS expects Project.LastEvaluationId to reflect the id of the ongoing, not yet finished evaluation.
This invariant regressed in #2748

LoggingService now creates an evaluation build event context separate from sending project started events. This allows the Evaluator to set the evaluation Id on Project before the first evaluation event gets fired.
radical pushed a commit to radical/msbuild that referenced this pull request Jan 30, 2018
CPS expects Project.LastEvaluationId to reflect the id of the ongoing, not yet finished evaluation.
This invariant regressed in dotnet#2748

LoggingService now creates an evaluation build event context separate from sending project started events. This allows the Evaluator to set the evaluation Id on Project before the first evaluation event gets fired.
@panopticoncentral
panopticoncentral deleted the eval branch July 19, 2019 19:51
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.

6 participants