-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Adding tracking of properties with relevant events. #4461
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
Conversation
|
@KirillOsenkov FYI |
|
Some big questions before diving into the details:
|
|
For opt-in, we didn't want each project to be storing a hashset of up to 1K properties each for this. This includes not just environment reads, but reads of uninitialized properties and it adds up. For scope, we never discussed what you meant by "Build a scope environment" in our mail thread. I asked for clarification but didn't receive a response. In the meantime, @jeffkl , @cdmihai , @AndyGerlicher , @smera , and I contributed to what you see here. Can you explain what you had in mind? |
|
I think using the existing scope mechanisms would resolve the impact-of-tracking concerns, especially if the uninitialized-property code follows the existing flag. MSBuild doesn't have much notion of a scope, since all properties and items within a project are accessible almost all the time. But there is one: The actual Scope is later but that comment is much more informative: It's not clear to me offhand whether that can be directly used at evaluation time, or a separate related implementation would be required. |
rainersigwald
left a comment
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.
Am I correct that the current state is that this is opt-in via environment variable only, and thus that it removes reassignment-tracking from the non-opted-in binlog case?
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 check seems good, but is the described behavior a bug, @cdmihai?
rainersigwald
left a comment
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.
Let's turn this on, and consider turning it on by default when the binlog is on in a subsequent build, after perf measurement.
|
AB#1550971 |
Co-Authored-By: Rainer Sigwald <[email protected]>
Co-Authored-By: Rainer Sigwald <[email protected]>
Co-Authored-By: Rainer Sigwald <[email protected]>
Co-Authored-By: Rainer Sigwald <[email protected]>
Co-Authored-By: Rainer Sigwald <[email protected]>
…ogger settings are more discrete.
2f1d470 to
9d0c5f3
Compare
Failing test:
```
Microsoft.Build.UnitTests.Evaluation.EvaluationLogging_Tests.GivenOneProjectThereShouldBeOneStartedAndOneEndedEvent [FAIL]
Shouldly.ShouldAssertException : Shouldly uses your source code to generate its great error messages, build your test project with full debug information to get better error messages
The provided expression
should start with
"Evaluation started"
but was
"Property reassignment: $(MSBuildFrameworkToolsRoot)="\Microsoft.NET\Framework\" (previous value: "/Library/Frameworks/Mono.framework/Versions/6.4.0/lib/mono") at "
Stack Trace:
at Shouldly.ShouldlyCoreExtensions.AssertAwesomely[T] (T actual, System.Func`2[T,TResult] specifiedConstraint, System.Object originalActual, System.Object originalExpected, System.Func`1[TResult] customMessage, System.String shouldlyMethod) [0x00056] in <cd631af7e9d7403ea1721c3ce03185bf>:0
at Shouldly.ShouldBeStringTestExtensions.ShouldStartWith (System.String actual, System.String expected, System.Func`1[TResult] customMessage, Shouldly.Case caseSensitivity) [0x00014] in <cd631af7e9d7403ea1721c3ce03185bf>:0
at Shouldly.ShouldBeStringTestExtensions.ShouldStartWith (System.String actual, System.String expected) [0x00000] in <cd631af7e9d7403ea1721c3ce03185bf>:0
at Microsoft.Build.UnitTests.Evaluation.EvaluationLogging_Tests+<>c.<GivenOneProjectThereShouldBeOneStartedAndOneEndedEvent>b__4_0 (Microsoft.Build.Evaluation.Project project, Microsoft.Build.UnitTests.MockLogger firstEvaluationLogger) [0x00033] in <559c19036a814aa4b96da7f3191f05ee>:0
at Microsoft.Build.UnitTests.Evaluation.EvaluationLogging_Tests.AssertLoggingEvents (System.Action`2[T1,T2] loggingTest, Microsoft.Build.UnitTests.MockLogger firstEvaluationLogger, System.Func`2[T,TResult] reevaluationLoggerFactory) [0x000d3] in <559c19036a814aa4b96da7f3191f05ee>:0
at Microsoft.Build.UnitTests.Evaluation.EvaluationLogging_Tests.GivenOneProjectThereShouldBeOneStartedAndOneEndedEvent () [0x00009] in <559c19036a814aa4b96da7f3191f05ee>:0
at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <b60d3e0e49a1407283b1fb67d86fa164>:0
```
Recent commit:
```
commit 7150dc9
Author: Matt Neely <[email protected]>
Date: Mon Aug 19 13:59:31 2019 -0700
Adding tracking of properties with relevant events. (dotnet#4461)
...
```
.. changed how property changes get logged, causing this to show up in
the logs, when running the test on mono:
```
Property reassignment: $(MSBuildFrameworkToolsRoot)="\Microsoft.NET\Framework\" (previous value: "/Library/Frameworks/Mono.framework/Versions/6.4.0/lib/mono") at
```
.. before the `Evaluation started` line, causing the test to break.
Instead of making assumptions about the exact message strings, we can check for
exactly the events that we are interested in -
`ProjectEvaluationStartedEvent` and `ProjectEvaluationFinishedEvent`.
Failing test: ``` Microsoft.Build.UnitTests.Evaluation.EvaluationLogging_Tests.GivenOneProjectThereShouldBeOneStartedAndOneEndedEvent [FAIL] Shouldly.ShouldAssertException : Shouldly uses your source code to generate its great error messages, build your test project with full debug information to get better error messages The provided expression should start with "Evaluation started" but was "Property reassignment: $(MSBuildFrameworkToolsRoot)="\Microsoft.NET\Framework\" (previous value: "/Library/Frameworks/Mono.framework/Versions/6.4.0/lib/mono") at " Stack Trace: at Shouldly.ShouldlyCoreExtensions.AssertAwesomely[T] (T actual, System.Func`2[T,TResult] specifiedConstraint, System.Object originalActual, System.Object originalExpected, System.Func`1[TResult] customMessage, System.String shouldlyMethod) [0x00056] in <cd631af7e9d7403ea1721c3ce03185bf>:0 at Shouldly.ShouldBeStringTestExtensions.ShouldStartWith (System.String actual, System.String expected, System.Func`1[TResult] customMessage, Shouldly.Case caseSensitivity) [0x00014] in <cd631af7e9d7403ea1721c3ce03185bf>:0 at Shouldly.ShouldBeStringTestExtensions.ShouldStartWith (System.String actual, System.String expected) [0x00000] in <cd631af7e9d7403ea1721c3ce03185bf>:0 at Microsoft.Build.UnitTests.Evaluation.EvaluationLogging_Tests+<>c.<GivenOneProjectThereShouldBeOneStartedAndOneEndedEvent>b__4_0 (Microsoft.Build.Evaluation.Project project, Microsoft.Build.UnitTests.MockLogger firstEvaluationLogger) [0x00033] in <559c19036a814aa4b96da7f3191f05ee>:0 at Microsoft.Build.UnitTests.Evaluation.EvaluationLogging_Tests.AssertLoggingEvents (System.Action`2[T1,T2] loggingTest, Microsoft.Build.UnitTests.MockLogger firstEvaluationLogger, System.Func`2[T,TResult] reevaluationLoggerFactory) [0x000d3] in <559c19036a814aa4b96da7f3191f05ee>:0 at Microsoft.Build.UnitTests.Evaluation.EvaluationLogging_Tests.GivenOneProjectThereShouldBeOneStartedAndOneEndedEvent () [0x00009] in <559c19036a814aa4b96da7f3191f05ee>:0 at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&) at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <b60d3e0e49a1407283b1fb67d86fa164>:0 ``` Recent commit: ``` commit 7150dc9 Author: Matt Neely <[email protected]> Date: Mon Aug 19 13:59:31 2019 -0700 Adding tracking of properties with relevant events. (dotnet#4461) ... ``` .. changed how property changes get logged, causing the following to show up in the logs, when running the test on mono: ``` Property reassignment: $(MSBuildFrameworkToolsRoot)="\Microsoft.NET\Framework\" (previous value: "/Library/Frameworks/Mono.framework/Versions/6.4.0/lib/mono") at ``` .. before the `Evaluation started` line, causing the test to break. Instead of making assumptions about the exact message strings, we can check for exactly the events that we are interested in - `ProjectEvaluationStartedEvent` and `ProjectEvaluationFinishedEvent`.
This reverts commit 7150dc9.
…otnet#4461)" (dotnet#4663)" This reverts commit faf5e5d.
…otnet#4461)" (dotnet#4663)" This reverts commit faf5e5d. Fixing merge error in a comment. Fix another merge issue. Merge fix.
Description
This change introduces opt-in functionality that will track property usage and generate three events:
Opt-in is via the environment variable,
MSBuildLogPropertyTracking=1.It's implemented via a new class named PropertyTrackingEvaluatorDataWraper that implements IEvaluatorData<> and wraps the Evaluator's instance of IEvaluatorData<> to intercept get and set property calls.
Resolves #3432
Related to #2713
Customer Impact
BuildXL needs to know what environment variables took part in a build to correctly generate a graph. Without this functionality, environment variables that modify the graph will not be properly detected which will produce incorrect cache hits.
Regression?
No
Risk
Low risk, net new functionality which is opt-in. Performance testing shows no impact with these changes.
Test changes in this PR
New unit tests