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

Track required outputs by following output chains #1398

Merged
merged 10 commits into from
May 1, 2018

Conversation

natebosch
Copy link
Member

Fixes #1397

Add OptionalOutputTracker to cache the status of which outputs from
optional phases are required. Use the tracker to check which failed
outputs were required during the current build. Also pass the tracker
createMergedOutputDirectories and replace the logic which crawled the
other direction.

Fixes #1397

Add `OptionalOutputTracker` to cache the status of which outputs from
optional phases are required. Use the tracker to check which failed
outputs were required during the current build. Also pass the tracker
`createMergedOutputDirectories` and replace the logic which crawled the
other direction.
@natebosch natebosch requested review from jakemac53 and grouma May 1, 2018 15:42
@googlebot googlebot added the cla: yes Google is happy with the PR contributors label May 1, 2018
@natebosch
Copy link
Member Author

I took a look at putting this logic in FinalizedAssetReader and using that from createMergedOutputDirectories but it was snowballing a bit so I held off for now.

If we do that though this will close out #1033 since it would be reflected by the server as well.

Copy link
Member

@grouma grouma left a comment

Choose a reason for hiding this comment

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

Is there a way we can add a test to ensure we don't regress #1397

import 'graph.dart';
import 'node.dart';

class OptionalOutputTracker {
Copy link
Member

Choose a reason for hiding this comment

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

Doc comment here and below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

() =>
generatedNode.outputs
.any((o) => isRequired(o, currentlyChecking)) ||
_assetGraph
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't quite get this logic - why do we care about other outputs in the phase?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh - I think this is trying to handle the additional outputs of the same action?

Right now I think it is checking all outputs of the same phase which is a lot more than we actually want I believe. We could add an additional where after outputsForPhase that checks if the primary input is the same?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah I see, yeah that makes sense. Will switch to only those with the same primary input

Copy link
Contributor

Choose a reason for hiding this comment

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

We still need to either do the expectedOutputs trick I did there or add a where after the outputsToPhase though to retain the old logic right?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah added a where clause to check the primary inputs

Copy link
Contributor

@jakemac53 jakemac53 May 1, 2018

Choose a reason for hiding this comment

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

Lol I really wish github updated comments without having to refresh

@natebosch
Copy link
Member Author

Added a regression test and doc comments. PTAL

@jakemac53
Copy link
Contributor

This should make finishing #1033 easier as well yes?

@natebosch
Copy link
Member Author

Yes I believe that gets a lot easier to fix. Just need to decide how to structure it. There isn't a clear way to pass the OptionalOutputTracker through to the FinalizedAssetReader (or to the server handler directly) so we'll need to consider exactly whether we're OK with multiple instances, or if we want to add a field to BuildResult or something.

@jakemac53
Copy link
Contributor

jakemac53 commented May 1, 2018

There isn't a clear way to pass the OptionalOutputTracker through to the FinalizedAssetReader (or to the server handler directly) so we'll need to consider exactly whether we're OK with multiple instances, or if we want to add a field to BuildResult or something.

Ya - I think multiple instances is probably ok, or we could expose a wasRequired method on BuildResult which takes an AssetId (and internally uses the OptionalOutputTracker)?

@natebosch
Copy link
Member Author

or we could expose a wasRequired method on BuildResult which takes an AssetId

I was thinking I'd like to make a FinalizedAssetReader field on BuildResult, use OptionalOutputTracker in the reader (or just move the logic there), and make createMergedOutputDirectories use a FinalizedAssetReader.

I have been playing around a bit but I'm not really happy with it yet. I didn't want that work to block getting this fixed so I figured we could submit as is and refactor soon.

expect(result.stderr, contains('Failed'));

// Run a build with dart2js that should also fail. Makes the failing DDC
// outptus no longer necessary for the build but does not invalidate them
Copy link
Contributor

Choose a reason for hiding this comment

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

s/outptus/outputs

expect(result.exitCode, isNot(0));
expect(result.stderr, contains('Failed'));

// Run a build with dart2js that should also fail. Makes the failing DDC
Copy link
Contributor

@jakemac53 jakemac53 May 1, 2018

Choose a reason for hiding this comment

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

Not super stoked on relying on the internals here... also note that the ddc output is going to get marked as needing an update as well which might change the logic or hit different codepaths (not sure how we treat failures that didn't rerun).

I would instead create a new file with an error in it (but not imported anywhere) and expect as successful build, then add an import to it and expect a failure, then remove the import again and expect it to pass. This is I expect a common actual user scenario and better representation since there is still an up to date failing action that should simply be ignored.

Copy link
Member Author

Choose a reason for hiding this comment

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

As a bonus it's also much faster :)

Skipping the check for the successful build since I don't think it changes the meaning of the test.

@natebosch natebosch merged commit 51d0616 into master May 1, 2018
@natebosch natebosch deleted the optional-output-tracker branch May 1, 2018 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google is happy with the PR contributors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants