Unverified Commit 55710381 authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

turbo-tasks-fs: revert rename to last_invalidated_index

The batch only holds pending invalidations, so last_updated_index is the
more accurate name.
Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent d6fcbf02
...@@ -128,7 +128,7 @@ impl PendingBatch { ...@@ -128,7 +128,7 @@ impl PendingBatch {
turbo_tasks.send_compilation_event(Arc::new(FilesystemSettlingEvent { turbo_tasks.send_compilation_event(Arc::new(FilesystemSettlingEvent {
elapsed_secs: (now - self.started).as_secs_f64(), elapsed_secs: (now - self.started).as_secs_f64(),
last_modified_path: batch last_modified_path: batch
.last_invalidated_path() .last_updated_path()
.map(|path| RcStr::from(format!("{path:?}"))), .map(|path| RcStr::from(format!("{path:?}"))),
})); }));
} }
......
...@@ -858,9 +858,9 @@ struct BatchedInvalidations { ...@@ -858,9 +858,9 @@ struct BatchedInvalidations {
has_new_paths: bool, has_new_paths: bool,
/// Whether to track newly created paths, i.e. whether we're in non-recursive watching mode. /// Whether to track newly created paths, i.e. whether we're in non-recursive watching mode.
track_new_paths: bool, track_new_paths: bool,
/// The most recently invalidated entry in [`Self::paths`]. Never one that only has /// The most recently updated entry in [`Self::paths`]. Never one that only has
/// [`InvalidationFlags::NEW`]. /// [`InvalidationFlags::NEW`].
last_invalidated_index: Option<usize>, last_updated_index: Option<usize>,
/// Whether events are coming from [`PollWatcher`] instead of [`RecommendedWatcher`], which /// Whether events are coming from [`PollWatcher`] instead of [`RecommendedWatcher`], which
/// changes how a file content change is reported. See [`Self::is_content_change`]. /// changes how a file content change is reported. See [`Self::is_content_change`].
polling: bool, polling: bool,
...@@ -873,7 +873,7 @@ impl BatchedInvalidations { ...@@ -873,7 +873,7 @@ impl BatchedInvalidations {
has_invalidations: false, has_invalidations: false,
has_new_paths: false, has_new_paths: false,
track_new_paths: matches!(recursive_mode, DiskWatcherRecursiveMode::NonRecursive), track_new_paths: matches!(recursive_mode, DiskWatcherRecursiveMode::NonRecursive),
last_invalidated_index: None, last_updated_index: None,
polling, polling,
} }
} }
...@@ -909,7 +909,7 @@ impl BatchedInvalidations { ...@@ -909,7 +909,7 @@ impl BatchedInvalidations {
self.paths.clear(); self.paths.clear();
self.has_invalidations = false; self.has_invalidations = false;
self.has_new_paths = false; self.has_new_paths = false;
self.last_invalidated_index = None; self.last_updated_index = None;
} }
/// Whether the batch contains newly created paths. Always false in recursive watching mode. /// Whether the batch contains newly created paths. Always false in recursive watching mode.
...@@ -995,8 +995,8 @@ impl BatchedInvalidations { ...@@ -995,8 +995,8 @@ impl BatchedInvalidations {
} }
} }
fn last_invalidated_path(&self) -> Option<&Path> { fn last_updated_path(&self) -> Option<&Path> {
self.last_invalidated_index self.last_updated_index
.and_then(|index| self.paths.get_index(index)) .and_then(|index| self.paths.get_index(index))
.map(|(path, _)| &**path) .map(|(path, _)| &**path)
} }
...@@ -1052,12 +1052,12 @@ impl BatchedInvalidations { ...@@ -1052,12 +1052,12 @@ impl BatchedInvalidations {
}; };
let paths = event.paths; let paths = event.paths;
let mut last_invalidated_index = None; let mut last_updated_index = None;
match event.kind { match event.kind {
EventKind::Modify(ModifyKind::Data(_)) => { EventKind::Modify(ModifyKind::Data(_)) => {
for path in paths { for path in paths {
if is_relevant(self, &path, None, false) { if is_relevant(self, &path, None, false) {
last_invalidated_index = last_updated_index =
Some(self.mark(Cow::Owned(path), InvalidationFlags::PATH)); Some(self.mark(Cow::Owned(path), InvalidationFlags::PATH));
} }
} }
...@@ -1066,7 +1066,7 @@ impl BatchedInvalidations { ...@@ -1066,7 +1066,7 @@ impl BatchedInvalidations {
EventKind::Modify(ModifyKind::Metadata(kind)) if self.is_content_change(kind) => { EventKind::Modify(ModifyKind::Metadata(kind)) if self.is_content_change(kind) => {
for path in paths { for path in paths {
if is_relevant(self, &path, None, false) { if is_relevant(self, &path, None, false) {
last_invalidated_index = last_updated_index =
Some(self.mark(Cow::Owned(path), InvalidationFlags::PATH)); Some(self.mark(Cow::Owned(path), InvalidationFlags::PATH));
} }
} }
...@@ -1074,7 +1074,7 @@ impl BatchedInvalidations { ...@@ -1074,7 +1074,7 @@ impl BatchedInvalidations {
EventKind::Modify(ModifyKind::Metadata(_)) => { EventKind::Modify(ModifyKind::Metadata(_)) => {
for path in paths { for path in paths {
if metadata_invalidator_map_guard.contains_key(path.as_path()) { if metadata_invalidator_map_guard.contains_key(path.as_path()) {
last_invalidated_index = last_updated_index =
Some(self.mark(Cow::Owned(path), InvalidationFlags::PATH_METADATA)); Some(self.mark(Cow::Owned(path), InvalidationFlags::PATH_METADATA));
} }
} }
...@@ -1086,7 +1086,7 @@ impl BatchedInvalidations { ...@@ -1086,7 +1086,7 @@ impl BatchedInvalidations {
continue; continue;
} }
self.mark_parent_dir(&path); self.mark_parent_dir(&path);
last_invalidated_index = Some(self.mark( last_updated_index = Some(self.mark(
Cow::Owned(path), Cow::Owned(path),
InvalidationFlags::PATH_AND_CHILDREN InvalidationFlags::PATH_AND_CHILDREN
| InvalidationFlags::PATH_AND_CHILDREN_DIR, | InvalidationFlags::PATH_AND_CHILDREN_DIR,
...@@ -1099,7 +1099,7 @@ impl BatchedInvalidations { ...@@ -1099,7 +1099,7 @@ impl BatchedInvalidations {
continue; continue;
} }
self.mark_parent_dir(&path); self.mark_parent_dir(&path);
last_invalidated_index = Some(self.mark( last_updated_index = Some(self.mark(
Cow::Owned(path), Cow::Owned(path),
InvalidationFlags::PATH_AND_CHILDREN InvalidationFlags::PATH_AND_CHILDREN
| InvalidationFlags::PATH_AND_CHILDREN_DIR, | InvalidationFlags::PATH_AND_CHILDREN_DIR,
...@@ -1113,14 +1113,14 @@ impl BatchedInvalidations { ...@@ -1113,14 +1113,14 @@ impl BatchedInvalidations {
if is_relevant(self, &source, source.parent(), true) { if is_relevant(self, &source, source.parent(), true) {
self.mark_parent_dir(&source); self.mark_parent_dir(&source);
last_invalidated_index = last_updated_index =
Some(self.mark(Cow::Owned(source), InvalidationFlags::PATH_AND_CHILDREN)); Some(self.mark(Cow::Owned(source), InvalidationFlags::PATH_AND_CHILDREN));
} }
self.mark_new_path(&destination); self.mark_new_path(&destination);
if is_relevant(self, &destination, destination.parent(), true) { if is_relevant(self, &destination, destination.parent(), true) {
self.mark_parent_dir(&destination); self.mark_parent_dir(&destination);
last_invalidated_index = Some(self.mark( last_updated_index = Some(self.mark(
Cow::Owned(destination), Cow::Owned(destination),
InvalidationFlags::PATH_AND_CHILDREN, InvalidationFlags::PATH_AND_CHILDREN,
)); ));
...@@ -1135,7 +1135,7 @@ impl BatchedInvalidations { ...@@ -1135,7 +1135,7 @@ impl BatchedInvalidations {
continue; continue;
} }
self.mark_parent_dir(&path); self.mark_parent_dir(&path);
last_invalidated_index = Some(self.mark( last_updated_index = Some(self.mark(
Cow::Owned(path), Cow::Owned(path),
InvalidationFlags::PATH_AND_CHILDREN InvalidationFlags::PATH_AND_CHILDREN
| InvalidationFlags::PATH_AND_CHILDREN_DIR, | InvalidationFlags::PATH_AND_CHILDREN_DIR,
...@@ -1144,8 +1144,8 @@ impl BatchedInvalidations { ...@@ -1144,8 +1144,8 @@ impl BatchedInvalidations {
} }
EventKind::Modify(ModifyKind::Other) | EventKind::Access(_) | EventKind::Other => {} EventKind::Modify(ModifyKind::Other) | EventKind::Access(_) | EventKind::Other => {}
} }
if let Some(index) = last_invalidated_index { if let Some(index) = last_updated_index {
self.last_invalidated_index = Some(index); self.last_updated_index = Some(index);
true true
} else { } else {
false false
...@@ -1156,10 +1156,10 @@ impl BatchedInvalidations { ...@@ -1156,10 +1156,10 @@ impl BatchedInvalidations {
fn add_error(&mut self, paths: Vec<PathBuf>, root_path: &Path) { fn add_error(&mut self, paths: Vec<PathBuf>, root_path: &Path) {
let flags = InvalidationFlags::PATH_AND_CHILDREN | InvalidationFlags::PATH_AND_CHILDREN_DIR; let flags = InvalidationFlags::PATH_AND_CHILDREN | InvalidationFlags::PATH_AND_CHILDREN_DIR;
if paths.is_empty() { if paths.is_empty() {
self.last_invalidated_index = Some(self.mark(Cow::Borrowed(root_path), flags)); self.last_updated_index = Some(self.mark(Cow::Borrowed(root_path), flags));
} else { } else {
for path in paths { for path in paths {
self.last_invalidated_index = Some(self.mark(Cow::Owned(path), flags)); self.last_updated_index = Some(self.mark(Cow::Owned(path), flags));
} }
} }
} }
...@@ -1403,7 +1403,7 @@ mod tests { ...@@ -1403,7 +1403,7 @@ mod tests {
relevant, relevant,
"{kind:?} at {path}", "{kind:?} at {path}",
); );
assert_eq!(batch.last_invalidated_path().is_some(), relevant); assert_eq!(batch.last_updated_path().is_some(), relevant);
} }
anyhow::Ok(()) anyhow::Ok(())
}) })
...@@ -1546,7 +1546,7 @@ mod tests { ...@@ -1546,7 +1546,7 @@ mod tests {
assert!(!add(&mut batch, create, "a")); assert!(!add(&mut batch, create, "a"));
assert!(batch.has_new_paths()); assert!(batch.has_new_paths());
assert!(!batch.has_pending_invalidations()); assert!(!batch.has_pending_invalidations());
assert_eq!(batch.last_invalidated_path(), None); assert_eq!(batch.last_updated_path(), None);
assert_eq!(batch.paths[Path::new("a")], InvalidationFlags::NEW); assert_eq!(batch.paths[Path::new("a")], InvalidationFlags::NEW);
// neither a repeated creation, nor events on the path or its children become relevant // neither a repeated creation, nor events on the path or its children become relevant
...@@ -1555,7 +1555,7 @@ mod tests { ...@@ -1555,7 +1555,7 @@ mod tests {
assert!(!add(&mut batch, content, "a")); assert!(!add(&mut batch, content, "a"));
assert!(!add(&mut batch, create, "a/b")); assert!(!add(&mut batch, create, "a/b"));
assert!(!batch.has_pending_invalidations()); assert!(!batch.has_pending_invalidations());
assert_eq!(batch.last_invalidated_path(), None); assert_eq!(batch.last_updated_path(), None);
assert_eq!(batch.paths[Path::new("a/b")], InvalidationFlags::NEW); assert_eq!(batch.paths[Path::new("a/b")], InvalidationFlags::NEW);
// only restored paths keep the flag // only restored paths keep the flag
...@@ -1577,10 +1577,10 @@ mod tests { ...@@ -1577,10 +1577,10 @@ mod tests {
// are relevant // are relevant
assert!(add(&mut batch, content, "a")); assert!(add(&mut batch, content, "a"));
assert!(add(&mut batch, create, "a/c")); assert!(add(&mut batch, create, "a/c"));
assert_eq!(batch.last_invalidated_path(), Some(Path::new("a/c"))); assert_eq!(batch.last_updated_path(), Some(Path::new("a/c")));
batch.clear(); batch.clear();
assert_eq!(batch.last_invalidated_path(), None); assert_eq!(batch.last_updated_path(), None);
assert!(!add(&mut batch, create, "a")); assert!(!add(&mut batch, create, "a"));
batch.clear(); batch.clear();
assert!(!batch.has_pending_invalidations()); assert!(!batch.has_pending_invalidations());
...@@ -1599,11 +1599,11 @@ mod tests { ...@@ -1599,11 +1599,11 @@ mod tests {
} }
/// Filtering and promoting new paths must preserve existing invalidation flags on the same /// Filtering and promoting new paths must preserve existing invalidation flags on the same
/// path, as well as the last invalidated path. /// path, as well as the last updated path.
#[test] #[test]
fn new_flag_is_independent_of_invalidations() { fn new_flag_is_independent_of_invalidations() {
let mut batch = BatchedInvalidations::new(DiskWatcherRecursiveMode::NonRecursive, false); let mut batch = BatchedInvalidations::new(DiskWatcherRecursiveMode::NonRecursive, false);
batch.last_invalidated_index = batch.last_updated_index =
Some(batch.mark(Cow::Borrowed(Path::new("a")), InvalidationFlags::PATH)); Some(batch.mark(Cow::Borrowed(Path::new("a")), InvalidationFlags::PATH));
batch.mark_new_path(Path::new("a")); batch.mark_new_path(Path::new("a"));
batch.mark_new_path(Path::new("b")); batch.mark_new_path(Path::new("b"));
...@@ -1623,7 +1623,7 @@ mod tests { ...@@ -1623,7 +1623,7 @@ mod tests {
assert_eq!(batch.paths[Path::new("a")], InvalidationFlags::PATH); assert_eq!(batch.paths[Path::new("a")], InvalidationFlags::PATH);
assert!(batch.paths[Path::new("b")].is_empty()); assert!(batch.paths[Path::new("b")].is_empty());
assert!(batch.has_pending_invalidations()); assert!(batch.has_pending_invalidations());
assert_eq!(batch.last_invalidated_path(), Some(Path::new("a"))); assert_eq!(batch.last_updated_path(), Some(Path::new("a")));
} }
/// Polls [`tracked_read`] until it has executed more than `previous_runs` times, i.e. until the /// Polls [`tracked_read`] until it has executed more than `previous_runs` times, i.e. until the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment