Rebuild the snapshot when bin/ or lib/ has uncommitted edits - #71
Closed
DenisovAV wants to merge 1 commit into
Closed
Rebuild the snapshot when bin/ or lib/ has uncommitted edits#71DenisovAV wants to merge 1 commit into
DenisovAV wants to merge 1 commit into
Conversation
`tool_revision` returns the git HEAD SHA in a checkout, and the stamp holds the revision from the last successful compile. HEAD does not move for an uncommitted edit, so the two match and the snapshot is reused: editing the tool and re-running it silently executes the previous build. The file-hashing branch of `tool_revision` would catch it, but it only runs when there is no `.git`. Always hashing instead of taking the SHA shortcut is correct but costs ~0.6s on every invocation (52 files under bin/ and lib/), which is presumably why the shortcut exists. An mtime probe answers the same question in ~9ms: `-print -quit` stops at the first file newer than the stamp, and the stamp is rewritten after every successful compile. Same shape as the `pubspec.yaml -nt` check directly above it. Verified against the built snapshot: with the probe, a warm run does not recompile, `touch lib/tvos_plugins.dart` makes the next run recompile, and the run after that does not. On the unpatched script the same edit produces no recompile at all.
Contributor
Author
|
Folded into #70 instead — one PR rather than three. The change is unrelated to the 3.32.8 port, but it is one hunk and not worth its own review round. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Editing the tool and re-running it silently executes the previous snapshot.
tool_revision()returns the git HEAD SHA when.gitis present, andbin/cache/flutter-tvos.stampholds the revision from the last successful compile. An uncommitted edit does not move HEAD, so the two match, the recompile is skipped, and the old snapshot runs. Nothing is printed. The file-hashing branch oftool_revision()would catch it, but it only runs when there is no.git— i.e. never during development.Why not just always hash
That is the obviously correct fix, and it is what the fallback branch does. Measured here: 52 files under
bin/andlib/, ~0.61s per invocation. Paying that on everyflutter-tvoscommand is presumably why the SHA shortcut exists in the first place.An mtime probe answers the same question for ~9ms —
-print -quitstops at the first file newer than the stamp, and the stamp is rewritten after every successful compile, so it is a reliable "we have already built this state" marker. That is the same shape as the"$ROOT_DIR/pubspec.yaml" -nt "$stamp_path"check directly above it, so it fits the file rather than introducing a new mechanism.Verified against a real built snapshot
touch lib/tvos_plugins.dart, runThe third row is the bug: same edit, same command, and on the unpatched script the tool keeps running the stale binary.
Found while working on the 3.32.8 line — a source change appeared to have no effect, which cost a debugging cycle chasing the wrong thing.