Skip to content

Conversation

@jesseschalken
Copy link
Contributor

@jesseschalken jesseschalken commented Oct 22, 2025

Apple supports fstatat on macOS >=10.10 (source), and according to Platform Support the oldest supported version is 10.12.

Google says iOS >=10 supports fstatat but doesn't provide a source. *-apple-ios says the minimum supported iOS version is 10.0.

Unsure about tvOS, watchOS and visionOS, hoping CI can confirm this.

I am testing with fastdu which is effectively a stress test for DirEntry::metadata. In one test this provides a 1.13x speedup.

$ hyperfine --warmup 1 'target/release/fastdu testdir' 'fastdu testdir'
Benchmark 1: target/release/fastdu testdir
  Time (mean ± σ):     154.6 ms ±  17.4 ms    [User: 31.7 ms, System: 187.6 ms]
  Range (min … max):   148.4 ms … 225.5 ms    19 runs
 
Benchmark 2: fastdu testdir
  Time (mean ± σ):     175.3 ms ±  15.8 ms    [User: 50.0 ms, System: 196.2 ms]
  Range (min … max):   165.4 ms … 211.7 ms    17 runs
 
Summary
  target/release/fastdu testdir ran
    1.13 ± 0.16 times faster than fastdu testdir

You can also reproduce a speedup with a program like this (providing a directory with many entries):

fn main() {
    let args: Vec<_> = std::env::args_os().collect();
    let dir: PathBuf = args[1].clone().into();

    for entry in dir.read_dir().as_mut().unwrap() {
        let entry = entry.as_ref().unwrap();
        let metadata = entry.metadata();
        let metadata = metadata.as_ref().unwrap();
        println!("{} {}", metadata.len(), entry.file_name().display());
    }
}
$ hyperfine './target/release/main testdir' './main testdir'
Benchmark 1: ./target/release/main testdir
  Time (mean ± σ):     148.3 ms ±   5.2 ms    [User: 23.1 ms, System: 122.9 ms]
  Range (min … max):   145.2 ms … 167.2 ms    19 runs
 
Benchmark 2: ./main testdir
  Time (mean ± σ):     164.4 ms ±   9.5 ms    [User: 32.6 ms, System: 128.8 ms]
  Range (min … max):   158.5 ms … 199.5 ms    17 runs
 
Summary
  ./target/release/main testdir ran
    1.11 ± 0.07 times faster than ./main testdir

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 22, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 22, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rust-log-analyzer

This comment has been minimized.

Copy link
Contributor

@BlackHoleFox BlackHoleFox left a comment

Choose a reason for hiding this comment

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

Looks good to me. fstatat is in all of the various SDK's public headers and its more darwin functionality then anything platform specific. And yeah available before Rust's current minimum Apple OS versions.

View changes since this review

@joboet
Copy link
Member

joboet commented Oct 31, 2025

Cool!
@bors r+
r? joboet

@bors
Copy link
Collaborator

bors commented Oct 31, 2025

📌 Commit fe4c2a2 has been approved by joboet

It is now in the queue for this repository.

@rustbot rustbot assigned joboet and unassigned Mark-Simulacrum Oct 31, 2025
@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 31, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 31, 2025
…=joboet

Use fstatat() in DirEntry::metadata on Apple platforms

Apple supports `fstatat` on macOS >=10.10 ([source](https://gitlab.gnome.org/GNOME/glib/-/issues/2203)), and according to [Platform Support](https://doc.rust-lang.org/beta/rustc/platform-support.html) the oldest supported version is 10.12.

Google says iOS >=10 supports `fstatat` but doesn't provide a source. [*-apple-ios](https://doc.rust-lang.org/beta/rustc/platform-support/apple-ios.html#os-version) says the minimum supported iOS version is 10.0.

Unsure about tvOS, watchOS and visionOS, hoping CI can confirm this.

I am testing with [fastdu](https://github.com/jesseschalken/fastdu) which is effectively a stress test for `DirEntry::metadata`. In one test this provides a **1.13x** speedup.

```
$ hyperfine --warmup 1 'target/release/fastdu testdir' 'fastdu testdir'
Benchmark 1: target/release/fastdu testdir
  Time (mean ± σ):     154.6 ms ±  17.4 ms    [User: 31.7 ms, System: 187.6 ms]
  Range (min … max):   148.4 ms … 225.5 ms    19 runs

Benchmark 2: fastdu testdir
  Time (mean ± σ):     175.3 ms ±  15.8 ms    [User: 50.0 ms, System: 196.2 ms]
  Range (min … max):   165.4 ms … 211.7 ms    17 runs

Summary
  target/release/fastdu testdir ran
    1.13 ± 0.16 times faster than fastdu testdir
```

You can also reproduce a speedup with a program like this (providing a directory with many entries):

```rust
fn main() {
    let args: Vec<_> = std::env::args_os().collect();
    let dir: PathBuf = args[1].clone().into();

    for entry in dir.read_dir().as_mut().unwrap() {
        let entry = entry.as_ref().unwrap();
        let metadata = entry.metadata();
        let metadata = metadata.as_ref().unwrap();
        println!("{} {}", metadata.len(), entry.file_name().display());
    }
}
```

```
$ hyperfine './target/release/main testdir' './main testdir'
Benchmark 1: ./target/release/main testdir
  Time (mean ± σ):     148.3 ms ±   5.2 ms    [User: 23.1 ms, System: 122.9 ms]
  Range (min … max):   145.2 ms … 167.2 ms    19 runs

Benchmark 2: ./main testdir
  Time (mean ± σ):     164.4 ms ±   9.5 ms    [User: 32.6 ms, System: 128.8 ms]
  Range (min … max):   158.5 ms … 199.5 ms    17 runs

Summary
  ./target/release/main testdir ran
    1.11 ± 0.07 times faster than ./main testdir
```
bors added a commit that referenced this pull request Oct 31, 2025
Rollup of 9 pull requests

Successful merges:

 - #139310 (add first HelenOS compilation targets)
 - #147161 (implement VecDeque extend_from_within and prepend_from_within)
 - #147622 (`unicode_data` refactors)
 - #147780 (Implement VecDeque::extract_if)
 - #147942 (Enable regression labeling aliases)
 - #147986 (Use fstatat() in DirEntry::metadata on Apple platforms)
 - #148103 (cg_llvm: Pass `debuginfo_compression` through FFI as an enum)
 - #148319 (docs: Fix argument names for `carrying_mul_add`)
 - #148322 (Enable file locking support in illumos)

r? `@ghost`
`@rustbot` modify labels: rollup
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 1, 2025
…=joboet

Use fstatat() in DirEntry::metadata on Apple platforms

Apple supports `fstatat` on macOS >=10.10 ([source](https://gitlab.gnome.org/GNOME/glib/-/issues/2203)), and according to [Platform Support](https://doc.rust-lang.org/beta/rustc/platform-support.html) the oldest supported version is 10.12.

Google says iOS >=10 supports `fstatat` but doesn't provide a source. [*-apple-ios](https://doc.rust-lang.org/beta/rustc/platform-support/apple-ios.html#os-version) says the minimum supported iOS version is 10.0.

Unsure about tvOS, watchOS and visionOS, hoping CI can confirm this.

I am testing with [fastdu](https://github.com/jesseschalken/fastdu) which is effectively a stress test for `DirEntry::metadata`. In one test this provides a **1.13x** speedup.

```
$ hyperfine --warmup 1 'target/release/fastdu testdir' 'fastdu testdir'
Benchmark 1: target/release/fastdu testdir
  Time (mean ± σ):     154.6 ms ±  17.4 ms    [User: 31.7 ms, System: 187.6 ms]
  Range (min … max):   148.4 ms … 225.5 ms    19 runs

Benchmark 2: fastdu testdir
  Time (mean ± σ):     175.3 ms ±  15.8 ms    [User: 50.0 ms, System: 196.2 ms]
  Range (min … max):   165.4 ms … 211.7 ms    17 runs

Summary
  target/release/fastdu testdir ran
    1.13 ± 0.16 times faster than fastdu testdir
```

You can also reproduce a speedup with a program like this (providing a directory with many entries):

```rust
fn main() {
    let args: Vec<_> = std::env::args_os().collect();
    let dir: PathBuf = args[1].clone().into();

    for entry in dir.read_dir().as_mut().unwrap() {
        let entry = entry.as_ref().unwrap();
        let metadata = entry.metadata();
        let metadata = metadata.as_ref().unwrap();
        println!("{} {}", metadata.len(), entry.file_name().display());
    }
}
```

```
$ hyperfine './target/release/main testdir' './main testdir'
Benchmark 1: ./target/release/main testdir
  Time (mean ± σ):     148.3 ms ±   5.2 ms    [User: 23.1 ms, System: 122.9 ms]
  Range (min … max):   145.2 ms … 167.2 ms    19 runs

Benchmark 2: ./main testdir
  Time (mean ± σ):     164.4 ms ±   9.5 ms    [User: 32.6 ms, System: 128.8 ms]
  Range (min … max):   158.5 ms … 199.5 ms    17 runs

Summary
  ./target/release/main testdir ran
    1.11 ± 0.07 times faster than ./main testdir
```
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 1, 2025
…=joboet

Use fstatat() in DirEntry::metadata on Apple platforms

Apple supports `fstatat` on macOS >=10.10 ([source](https://gitlab.gnome.org/GNOME/glib/-/issues/2203)), and according to [Platform Support](https://doc.rust-lang.org/beta/rustc/platform-support.html) the oldest supported version is 10.12.

Google says iOS >=10 supports `fstatat` but doesn't provide a source. [*-apple-ios](https://doc.rust-lang.org/beta/rustc/platform-support/apple-ios.html#os-version) says the minimum supported iOS version is 10.0.

Unsure about tvOS, watchOS and visionOS, hoping CI can confirm this.

I am testing with [fastdu](https://github.com/jesseschalken/fastdu) which is effectively a stress test for `DirEntry::metadata`. In one test this provides a **1.13x** speedup.

```
$ hyperfine --warmup 1 'target/release/fastdu testdir' 'fastdu testdir'
Benchmark 1: target/release/fastdu testdir
  Time (mean ± σ):     154.6 ms ±  17.4 ms    [User: 31.7 ms, System: 187.6 ms]
  Range (min … max):   148.4 ms … 225.5 ms    19 runs

Benchmark 2: fastdu testdir
  Time (mean ± σ):     175.3 ms ±  15.8 ms    [User: 50.0 ms, System: 196.2 ms]
  Range (min … max):   165.4 ms … 211.7 ms    17 runs

Summary
  target/release/fastdu testdir ran
    1.13 ± 0.16 times faster than fastdu testdir
```

You can also reproduce a speedup with a program like this (providing a directory with many entries):

```rust
fn main() {
    let args: Vec<_> = std::env::args_os().collect();
    let dir: PathBuf = args[1].clone().into();

    for entry in dir.read_dir().as_mut().unwrap() {
        let entry = entry.as_ref().unwrap();
        let metadata = entry.metadata();
        let metadata = metadata.as_ref().unwrap();
        println!("{} {}", metadata.len(), entry.file_name().display());
    }
}
```

```
$ hyperfine './target/release/main testdir' './main testdir'
Benchmark 1: ./target/release/main testdir
  Time (mean ± σ):     148.3 ms ±   5.2 ms    [User: 23.1 ms, System: 122.9 ms]
  Range (min … max):   145.2 ms … 167.2 ms    19 runs

Benchmark 2: ./main testdir
  Time (mean ± σ):     164.4 ms ±   9.5 ms    [User: 32.6 ms, System: 128.8 ms]
  Range (min … max):   158.5 ms … 199.5 ms    17 runs

Summary
  ./target/release/main testdir ran
    1.11 ± 0.07 times faster than ./main testdir
```
bors added a commit that referenced this pull request Nov 1, 2025
Rollup of 9 pull requests

Successful merges:

 - #139310 (add first HelenOS compilation targets)
 - #147161 (implement VecDeque extend_from_within and prepend_from_within)
 - #147622 (`unicode_data` refactors)
 - #147780 (Implement VecDeque::extract_if)
 - #147942 (Enable regression labeling aliases)
 - #147986 (Use fstatat() in DirEntry::metadata on Apple platforms)
 - #148103 (cg_llvm: Pass `debuginfo_compression` through FFI as an enum)
 - #148319 (docs: Fix argument names for `carrying_mul_add`)
 - #148322 (Enable file locking support in illumos)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c438dbd into rust-lang:master Nov 1, 2025
11 checks passed
@rustbot rustbot added this to the 1.93.0 milestone Nov 1, 2025
rust-timer added a commit that referenced this pull request Nov 1, 2025
Rollup merge of #147986 - jesseschalken:use-fstatat-macos, r=joboet

Use fstatat() in DirEntry::metadata on Apple platforms

Apple supports `fstatat` on macOS >=10.10 ([source](https://gitlab.gnome.org/GNOME/glib/-/issues/2203)), and according to [Platform Support](https://doc.rust-lang.org/beta/rustc/platform-support.html) the oldest supported version is 10.12.

Google says iOS >=10 supports `fstatat` but doesn't provide a source. [*-apple-ios](https://doc.rust-lang.org/beta/rustc/platform-support/apple-ios.html#os-version) says the minimum supported iOS version is 10.0.

Unsure about tvOS, watchOS and visionOS, hoping CI can confirm this.

I am testing with [fastdu](https://github.com/jesseschalken/fastdu) which is effectively a stress test for `DirEntry::metadata`. In one test this provides a **1.13x** speedup.

```
$ hyperfine --warmup 1 'target/release/fastdu testdir' 'fastdu testdir'
Benchmark 1: target/release/fastdu testdir
  Time (mean ± σ):     154.6 ms ±  17.4 ms    [User: 31.7 ms, System: 187.6 ms]
  Range (min … max):   148.4 ms … 225.5 ms    19 runs

Benchmark 2: fastdu testdir
  Time (mean ± σ):     175.3 ms ±  15.8 ms    [User: 50.0 ms, System: 196.2 ms]
  Range (min … max):   165.4 ms … 211.7 ms    17 runs

Summary
  target/release/fastdu testdir ran
    1.13 ± 0.16 times faster than fastdu testdir
```

You can also reproduce a speedup with a program like this (providing a directory with many entries):

```rust
fn main() {
    let args: Vec<_> = std::env::args_os().collect();
    let dir: PathBuf = args[1].clone().into();

    for entry in dir.read_dir().as_mut().unwrap() {
        let entry = entry.as_ref().unwrap();
        let metadata = entry.metadata();
        let metadata = metadata.as_ref().unwrap();
        println!("{} {}", metadata.len(), entry.file_name().display());
    }
}
```

```
$ hyperfine './target/release/main testdir' './main testdir'
Benchmark 1: ./target/release/main testdir
  Time (mean ± σ):     148.3 ms ±   5.2 ms    [User: 23.1 ms, System: 122.9 ms]
  Range (min … max):   145.2 ms … 167.2 ms    19 runs

Benchmark 2: ./main testdir
  Time (mean ± σ):     164.4 ms ±   9.5 ms    [User: 32.6 ms, System: 128.8 ms]
  Range (min … max):   158.5 ms … 199.5 ms    17 runs

Summary
  ./target/release/main testdir ran
    1.11 ± 0.07 times faster than ./main testdir
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants