Repository navigation
perf(macos): do not open files that have not changed when using the incremental cache - #1491
Merged
Merged
Conversation
dsherret
force-pushed
the
perf/incremental-file-stats
branch
from
November 30, 2026 16:06
d83dde3 to
0470000
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.
With a warm incremental cache, every file was opened and hashed only to find out that it did not change. Opening a file is slow on macOS (about 8µs, compared to under 1µs for a stat), and only scales to a few threads there.
This stores the stats of files (size, modified time, change time, inode and device) along with the hash of their contents, so a file whose stats are the same does not need to be opened. The stat is done where the file would be read, right before opening it.
When it's trusted
Only on macOS
dprint checkto say that a changed file is formatted. A write through a memory mapping does not change any of a file's times, and a directory listing additionally does not have the changes made through another hard link or to a file that's still open.On macOS, the stats caught every way of changing a file that I tried: setting the modified time back, replacing it with a file that has the same size and time, writing through a hard link, writing through a memory mapping, and while it's still open.
Where it's stored. In the incremental file, which has a
-statssuffix and the stats before the hashes when stats are used. Only that one file is read and written. Elsewhere and on the CI, the file's name and format don't change, so its bytes stay the same when nothing changed (ex. for a CI cache).dprint checkon an M2 Pro:Not tested: network file systems, which may cache attributes.