Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
## 2025-05-19 - File Discovery Allocations
**Learning:** In `discover_importing_files`, `WalkBuilder` results were being converted to `PathBuf` via `.map(|e| e.into_path())` *before* filtering. This caused allocations for every single file in the workspace (including excluded files and directories).
**Action:** Filter `ignore::DirEntry` directly using `entry.file_type()` and `entry.path()` before mapping to `PathBuf`. This avoids allocations for non-matching files.

## 2024-06-06 - Directory Traversal Stat Syscalls
**Learning:** Calling `entry.path().is_file()` on `ignore::DirEntry` triggers an unnecessary `stat` syscall for every entry, becoming a bottleneck during directory traversals.
**Action:** Always use `entry.file_type().is_some_and(|ft| ft.is_file())` instead to reuse metadata from `readdir`.
3 changes: 2 additions & 1 deletion crates/mill-handlers/src/handlers/common/checksums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ pub async fn calculate_checksums_for_directory_rename(
.build();

for entry in walker.flatten() {
if entry.path().is_file() {
// Use file_type() to avoid unnecessary stat syscalls
if entry.file_type().is_some_and(|ft| ft.is_file()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve symlinked files in directory checksums

When a directory contains a symlink to a regular file, this predicate now skips it because ignore::DirEntry::file_type() reports the entry itself as a symlink when WalkBuilder is using its default follow_links(false), whereas the previous entry.path().is_file() followed the link. Directory rename plans therefore omit those paths from file_checksums, so checksum validation no longer detects changes for symlinked files that are still moved as part of the directory operation; use metadata that follows links or explicitly handle symlinks if the previous behavior should be preserved.

Useful? React with πŸ‘Β / πŸ‘Ž.

if let Ok(content) = context.app_state.file_service.read_file(entry.path()).await {
file_checksums.insert(
entry.path().to_string_lossy().to_string(),
Expand Down
3 changes: 2 additions & 1 deletion crates/mill-handlers/src/handlers/prune_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,8 @@ impl PrunePlanner {
let walker = ignore::WalkBuilder::new(&abs_dir).hidden(false).build();
let files = walker
.flatten()
.filter(|entry| entry.path().is_file())
// Use file_type() to avoid unnecessary stat syscalls
.filter(|entry| entry.file_type().is_some_and(|ft| ft.is_file()))
.map(|entry| entry.path().to_path_buf())
.collect();
Ok((files, abs_dir))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ impl RenameService {
let mut files_to_move = 0;
let walker = ignore::WalkBuilder::new(&old_path).hidden(false).build();
for entry in walker.flatten() {
if entry.path().is_file() {
// Use file_type() to avoid unnecessary stat syscalls
if entry.file_type().is_some_and(|ft| ft.is_file()) {
files_to_move += 1;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@ impl FileService {
let mut files = Vec::new();
let walker = ignore::WalkBuilder::new(dir).hidden(false).build();
for entry in walker.flatten() {
if entry.path().is_file() {
// Use file_type() to avoid unnecessary stat syscalls
if entry.file_type().is_some_and(|ft| ft.is_file()) {
files.push(entry.path().to_path_buf());
}
}
Expand Down
Loading