Repository navigation
Take the source stat before reading the source - #3440
Merged
Merged
Conversation
A module's .tydb records the hash and the stat of the source that the build compiled. A later plan trusts the .tydb without reading the source when the source's stat is unchanged and older than the .tydb. The new tests write a new version of a source right after a build has read it. They cover the three places where a build reads a source: the first read of a new module, the read of a changed module, and the read for the front passes of a module whose own source is unchanged. All three fail here. The build takes the stat after the read, so the .tydb pairs the hash of the version that was read with the stat of the new version. The next plan trusts that .tydb and never compiles the new version.
A module's .tydb records the hash and the stat of the source that the build compiled. A later plan trusts the .tydb without reading the source when the source's stat equals the recorded one and is older than the .tydb. This rule holds only if the recorded stat is the stat of the version that was compiled, or of an older version. Before, the build took the stat after it had read the source. It did so when it read a new or changed module, and when it read an unchanged module again to run its front passes. A write that landed between the read and the stat gave a .tydb with the hash of the old version and the stat of the new version. Every later plan trusted that .tydb, so the new version was not compiled until the file changed again. After, the build takes the stat first and then reads the file once. A write that lands during the read leaves the file with a stat other than the recorded one, so the next plan hashes the source and compiles the new version. readModuleSource does this for every read of a module that is compiled. An editor overlay records no stat. The disk source provider now reads a file once and decodes the bytes as UTF-8. It used to read the text and the bytes through two handles, and the text was read lazily while the parser consumed it. So the parsed text could come from a later version of the file than the hashed bytes. A source that is not valid UTF-8 now fails with acton: src/a.act: invalid argument (cannot decode byte 0xff as UTF-8) where it failed with acton: src/a.act: hGetContents: invalid argument (cannot decode byte sequence starting from 255) SourceSnapshot loses its ssIsOverlay field. A snapshot is an overlay when spReadOverlay returned it.
plajjan
force-pushed
the
source-stat-before-read
branch
from
November 22, 2026 14:22
5d7038f to
ce48bbe
Compare
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.
A build took a module's stat after reading its source, so a write landing during the read left a .tydb that paired the hash of the old content with the stat of the new file, and later builds trusted that stat and never compiled the new version. The stat is now taken before a single read that gives both the parsed text and the hashed bytes.