Skip to content

Skip build when nothing changed. - #5157

Merged
davidmorgan merged 1 commit into
dart-lang:masterfrom
davidmorgan:skip-empty-build
Sep 22, 2026
Merged

davidmorgan merged 1 commit into
dart-lang:masterfrom
davidmorgan:skip-empty-build

Conversation

@davidmorgan

@davidmorgan davidmorgan commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

BuildSeries.run always ran a build, even when the scan of changed files found nothing that could affect any output. A file can be written without changing its content, and one logical write can produce more than one filesystem watch event, so watch and serve hit this case routinely and respond with a build that reports wrote 0 outputs.

Move buildLog.nextBuild after updateForFileChanges so the decision to build is taken once the scan has run, and return the previous result when the updated plan has no work.

Only a successful previous result can be reused. The scan answers whether anything changed since the last build, not whether the last result is still valid; after a failure those differ, and under --only-check a restored output would never be re-verified.

The updated plan is kept rather than discarded, so the content read during the scan is what the next change is compared against.

Fixes some test flakes that happened under load.

`BuildSeries.run` always ran a build, even when the scan of changed files
found nothing that could affect any output. A file can be written without
changing its content, and one logical write can produce more than one
filesystem watch event, so `watch` and `serve` hit this case routinely and
respond with a build that reports `wrote 0 outputs`.

Move `buildLog.nextBuild` after `updateForFileChanges` so the decision to
build is taken once the scan has run, and return the previous result when the
updated plan has no work.

Only a successful previous result can be reused. The scan answers whether
anything changed since the last build, not whether the last result is still
valid; after a failure those differ, and under `--only-check` a restored
output would never be re-verified.

The updated plan is kept rather than discarded, so the content read during the
scan is what the next change is compared against.
@davidmorgan
davidmorgan marked this pull request as ready for review September 22, 2026 12:09
@davidmorgan
davidmorgan merged commit b9f2eb8 into dart-lang:master Sep 22, 2026
57 checks passed
@davidmorgan
davidmorgan deleted the skip-empty-build branch September 22, 2026 13:28
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.

2 participants