# fs: Remove redundant stat in RealFs metadata \(\#63190\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/ad51f6825c362d930c78a6579eecd21a06a7055d)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: ad51f6825c362d930c78a6579eecd21a06a7055d

Requested commit: ad51f6825c362d930c78a6579eecd21a06a7055d

Commit: ad51f6825c362d930c78a6579eecd21a06a7055d

Tree: c389f7a6797771f8d64a1987e55dc7ace337d477

Author: Hamish Clark

Committer: GitHub

## Message

```
fs: Remove redundant stat in RealFs metadata (#63190)

# Objective

This removes an extra filesystem metadata lookup from
`RealFs::metadata`.

On Unix, `is_executable` performs a full extra stat(2)
(std::fs::metadata) just to read `mode() & 0o111`, even though the mode
bits are already present in the `symlink_metadata` result. On Windows
its impl also starts with `self.exists()`, another stat. This costs one
extra syscall plus one extra executor spawn per entry during the
worktree background scan - I experienced millions of avoidable syscalls
on a large monorepo.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable


---

Release Notes:

- Improved worktree scan performance by removing redundant executable
checks.

---------

Co-authored-by: Hamish <hamishc@users.noreply.github.com>
```

## Parents

- [e578430582432228101b9986c37f9141b64c5386](https://git.cafe/gitcafe/zed/commit/e578430582432228101b9986c37f9141b64c5386?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/ad51f6825c362d930c78a6579eecd21a06a7055d?format=markdown)
