Skip to content

Respect transforms in lazy eval#5447

Merged
rainersigwald merged 4 commits into
dotnet:masterfrom
rainersigwald:respect-transforms-in-lazy-eval
Jun 24, 2020
Merged

Respect transforms in lazy eval#5447
rainersigwald merged 4 commits into
dotnet:masterfrom
rainersigwald:respect-transforms-in-lazy-eval

Conversation

@rainersigwald
Copy link
Copy Markdown
Member

Fixes #5445 by checking to see if an item function is invoked (the captured
expression has subcaptures) before optimizing operations on same-item
captures.

Added regression tests and improved some asserts that didn't really help me when they fired.

fyi @cdmihai, @safern

@rainersigwald rainersigwald added this to the MSBuild 16.7 Preview 4 milestone Jun 18, 2020
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Curious, why use Filename instead of Identity?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was copy/pasting from the real repro :) Identity does make more sense.

Comment thread src/Build/Evaluation/LazyItemEvaluator.LazyItemOperation.cs Outdated
Copy link
Copy Markdown
Contributor

@cdmihai cdmihai left a comment

Choose a reason for hiding this comment

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

LGTM, pending comments.

Comment thread src/Build.UnitTests/Evaluation/ItemEvaluation_Tests.cs Outdated
@rainersigwald rainersigwald force-pushed the respect-transforms-in-lazy-eval branch from fbeea25 to a031d2f Compare June 22, 2020 18:17
Comment thread src/Build.UnitTests/Evaluation/ItemEvaluation_Tests.cs Outdated
@rainersigwald rainersigwald force-pushed the respect-transforms-in-lazy-eval branch from a031d2f to 2d5a47c Compare June 22, 2020 18:26
@ericstj
Copy link
Copy Markdown
Member

ericstj commented Jun 23, 2020

cc @mmitche who suggested getting this into Preview7

@rainersigwald
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Contributor

@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 don't actually know what evaluating an int does, but since it got this far, it's presumably fine. LGTM.

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.

nit:

Suggested change
<i Remove='@(i->`%(Extension)`)' /><!-- should do nothing -->";
<i Remove='@(i->`%(Extension)`)' /> <!-- should do nothing -->";

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.

nit:

Suggested change
<i Update=`@(i->'%(Extension)')`><!-- should do nothing -->
<i Update=`@(i->'%(Extension)')`> <!-- should do nothing -->

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.

Should this always return false or should it occasionally return true? I think this is only used for performance, so it doesn't matter if it has false negatives now, but I'd like to see if I understand it correctly. Also could be relevant if we start using it elsewhere.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It should always return false. The question this method answers is "can I just remove/update every item in the group, or do I need to expand the value to match against existing items?"

Renamed it for a bit more clarity there.

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.

Could we just move the assert up? Seems simpler.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That was my initial implementation, but it loses a bunch of information in the error message--it's nicer to see the item-level diff if there is one. That helped me chase down a couple of errors in this implementation.

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.

Suggested change
int minimumLength = Math.Min(expectedItems.Length, items.Count());
int minimumLength = Math.Min(expectedItems.Length, items.Count);

These fired while I was writing a new test but didn't have much useful information.

Keep AssertItems from throwing an ArgumentOutOfRangeException on mismatched lengths,
and give a clue or two about mismatched lengths in AssertItemHasMetadata.
Ensure that Update and Remove operations done at evaluation time that use
item functions pay attention to the item function and don't apply to all
items of the same type.
Fixes dotnet#5445 by checking to see if an item function is invoked (the captured
expression has subcaptures) before optimizing operations on same-item
captures.
The question this method answers is 'can I just remove/update every item in the group, or do I need to expand the value to match against existing items?'

Renamed it for a bit more clarity there.
@rainersigwald rainersigwald force-pushed the respect-transforms-in-lazy-eval branch from 2d5a47c to 0ffb5c4 Compare June 24, 2020 14:17
@rainersigwald rainersigwald merged commit 4511eaf into dotnet:master Jun 24, 2020
@rainersigwald rainersigwald deleted the respect-transforms-in-lazy-eval branch June 24, 2020 19:04
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.

Lazy evaluation optimizations don't respect item transforms

5 participants