Skip to content

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Sep 1, 2019

Description

We already have the information about the prior dag cached. When computing updates, uses the existing map of current output files to remove any old files that are no longer a part of the output.

There might be an edge case where a file is removed from the output of one target and added to the output of another, but I think that will be handled by comparing the filehashes (though I need more validation here anyway).

Removes manual deletion for asset and macOS rule.

Tests

  • Covered by existing test cases for asset deletion. Manually tested with macOS rule. Still leaves directories around but I don't think that is much of an issue.

@fluttergithubbot fluttergithubbot added the tool Affects the "flutter" command-line tool. See also t: labels. label Sep 1, 2019
@flutter flutter deleted a comment from fluttergithubbot Sep 1, 2019
@codecov
Copy link

codecov bot commented Sep 1, 2019

Codecov Report

Merging #39654 into master will increase coverage by 2.73%.
The diff coverage is 93.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #39654      +/-   ##
==========================================
+ Coverage   55.61%   58.34%   +2.73%     
==========================================
  Files         194      194              
  Lines       18726    18742      +16     
==========================================
+ Hits        10414    10935     +521     
+ Misses       8312     7807     -505
Flag Coverage Δ
#flutter_tool 58.34% <93.18%> (+2.73%) ⬆️
Impacted Files Coverage Δ
...er_tools/lib/src/build_system/targets/windows.dart 94.11% <ø> (ø) ⬆️
...tter_tools/lib/src/build_system/targets/linux.dart 94.44% <ø> (ø) ⬆️
...tter_tools/lib/src/build_system/targets/macos.dart 47.56% <ø> (-0.06%) ⬇️
...utter_tools/lib/src/build_system/build_system.dart 87.5% <93.18%> (+1.32%) ⬆️
packages/flutter_tools/lib/src/version.dart 90.9% <0%> (-1.92%) ⬇️
packages/flutter_tools/lib/src/cache.dart 43.5% <0%> (-0.73%) ⬇️
packages/flutter_tools/lib/src/devfs.dart 68.47% <0%> (+0.49%) ⬆️
packages/flutter_tools/lib/src/vmservice.dart 38.03% <0%> (+0.75%) ⬆️
packages/flutter_tools/lib/src/build_info.dart 75.4% <0%> (+1.09%) ⬆️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5a3a46a...16308ef. Read the comment docs.

}
}
return canSkip;
return _ChangeResult(previousOutputs, canSkip);
Copy link
Member

Choose a reason for hiding this comment

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

Consider caching the decoded stamp file json, and adding getters to the Target whose values are cached after being computed the first time. So, in this case, instead of returning _ChangeResult(...), it would go back to returning a bool, but Target would have a separate getter previousOutputs that is computed once using the decoded json that may or may not have already been cached itself.

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 think that to be ergonomic this needs some refactoring. The Target should not be used as the runtime representation of the build graph, that should be delegated to another interface which is mutable, allowing my to cache these values. That would potentially simplify the requirements for Source vs files too - Target could allow configuring sources, while the runtime representation could use Files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated this to have a runtime component which caches the outputs/inputs/stamp and deals only with files.

As a consequence, I'll need to deprecate/remove all the functionality that allowed for completely dynamic outputs (like output wildcards), but the tradeoff is worth it - I can now detect that a rule has changed only when the outputs change.

This ended up blocking the build assets with flutter assemble PR, since changing the output directory would not in of itself trigger a rebuild. After this PR it does.

// Malformed stamp file, not safe to skip.
_dirty = true;
} else {
final Map<String, Object> values = json.decode(content);
Copy link
Member

Choose a reason for hiding this comment

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

If the json is non-empty but corrupted somehow, then anything from here down could throw one of several exceptions. Maybe catch and set _dirty to true there too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated this to be safe, added test, unnested

@jonahwilliams jonahwilliams merged commit f877c97 into flutter:master Sep 10, 2019
@jonahwilliams jonahwilliams deleted the clean_old_files branch September 10, 2019 16:57
Inconnu08 pushed a commit to Inconnu08/flutter that referenced this pull request Sep 30, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants