Skip to content

⚡ Bolt: Avoid unnecessary stat syscalls in directory traversal#589

Open
mudcube wants to merge 1 commit into
mainfrom
bolt/optimize-dir-traversal-5967509655538779415
Open

⚡ Bolt: Avoid unnecessary stat syscalls in directory traversal#589
mudcube wants to merge 1 commit into
mainfrom
bolt/optimize-dir-traversal-5967509655538779415

Conversation

@mudcube

@mudcube mudcube commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

💡 What: Replaced entry.path().is_file() with entry.file_type().is_some_and(|ft| ft.is_file()) across directory traversal operations in mill-services and mill-handlers using ignore::WalkBuilder.

🎯 Why: Path::is_file() makes an explicit stat syscall (via fs::metadata) for every directory entry. The ignore and walkdir crates already retrieve the file type via readdir metadata when traversing. Accessing entry.file_type() reuses this cached data, eliminating thousands of unnecessary IO operations during operations like renaming, pruning, or checksum calculation on large workspaces.

📊 Impact: Reduces IO overhead during workspace-wide operations. Time spent making stat syscalls during file scans is largely eliminated.

🔬 Measurement: cargo test -p mill-services -p mill-handlers ensures functionally equivalent filtering (noting that symlinks to files are no longer traversed as regular files, aligning better with WalkBuilder default semantics). Performance can be verified by profiling operations on deeply nested, heavily populated directories.


PR created automatically by Jules for task 5967509655538779415 started by @mudcube

Co-authored-by: mudcube <101564+mudcube@users.noreply.github.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 8, 2026

Copy link
Copy Markdown

Deploying typemill with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7396d8c
Status: ✅  Deploy successful!
Preview URL: https://a3974076.typemill.pages.dev
Branch Preview URL: https://bolt-optimize-dir-traversal-s8is.typemill.pages.dev

View logs

@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7396d8c702

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

for entry in walker.flatten() {
if entry.path().is_file() {
// Optimize: avoid stat syscall by using readdir metadata
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 Include symlinked files in rename checksums

When the directory being renamed contains a symlink to a regular file, WalkBuilder still yields the symlink entry but entry.file_type() describes the link itself, so is_file() is false; the previous entry.path().is_file() followed the symlink. The rename still moves that symlink entry, while this helper is documented as checksumming all files inside the moved directory, so the generated plan now omits that affected path from file_checksums and checksum validation/affected-file reporting no longer covers it. Consider falling back to entry.path().is_file() for symlink entries or otherwise handling path_is_symlink() explicitly.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant