Skip to content

Commit

Permalink
detect 1 in a million changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gilescope committed May 27, 2024
1 parent a5daf56 commit bc2a8a3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/cargo/core/compiler/fingerprint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1887,6 +1887,9 @@ where
None
};

let mut truncated_precision_count : u64 = 0;
let mut total_checked: u64 = 0;
let mut first : Option<StaleItem> = None;
for path in paths {
let path = path.as_ref();

Expand Down Expand Up @@ -1931,10 +1934,20 @@ where
// Additionally, the build can span different volumes, some which support high-precision
// file timestamps and some that don't (e.g. mounted Docker volumes). This can make
// one of the timestamps lose the nanosecond part and appear up to a second in the past.
total_checked += 1;
let truncated_precision =
path_mtime.nanoseconds() == 0 || reference_mtime.nanoseconds() == 0;

let fresh = if truncated_precision {
truncated_precision_count += 1;
if first.is_none() {
first = Some(StaleItem::ChangedFile {
reference: reference.to_path_buf(),
reference_mtime,
stale: path.to_path_buf(),
stale_mtime: path_mtime,
});
}
path_mtime.unix_seconds() <= reference_mtime.unix_seconds()
} else {
path_mtime <= reference_mtime
Expand Down

0 comments on commit bc2a8a3

Please sign in to comment.