Skip to content

Comments

perf: use GetFileAttributesExW for symlink metadata lookup on Windows#691

Merged
graphite-app[bot] merged 1 commit intomainfrom
09-12-perf_use_getfileattributesexw_for_symlink_metadata_lookup_on_windows
Sep 12, 2025
Merged

perf: use GetFileAttributesExW for symlink metadata lookup on Windows#691
graphite-app[bot] merged 1 commit intomainfrom
09-12-perf_use_getfileattributesexw_for_symlink_metadata_lookup_on_windows

Conversation

@sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Sep 12, 2025

std::fs::symlink_metadata implementation uses GetFileInformationByHandle on Windows, which seems to be known as slow 1.

This PR adds a function that uses GetFileAttributesExW instead of it, which is faster than GetFileInformationByHandle.

Benchmarks

I tested this PR with rolldown/benchmarks. It improved the build time by ~10%
I took the following results with hyperfine 'node --run build:rolldown'

rome

Before

Benchmark 1: node --run build:rolldown
  Time (mean ± σ):     237.7 ms ±   3.7 ms    [User: 513.1 ms, System: 495.2 ms]
  Range (min … max):   233.1 ms … 243.5 ms    12 runs

After

Benchmark 1: node --run build:rolldown
  Time (mean ± σ):     210.4 ms ±   5.3 ms    [User: 422.1 ms, System: 443.5 ms]
  Range (min … max):   204.1 ms … 223.1 ms    13 runs

Result: -27.3ms (-11.5%)

three10x

Before

Benchmark 1: node --run build:rolldown
  Time (mean ± σ):     367.7 ms ±   5.1 ms    [User: 1313.1 ms, System: 1283.1 ms]
  Range (min … max):   359.7 ms … 374.5 ms    10 runs

After

Benchmark 1: node --run build:rolldown
  Time (mean ± σ):     334.3 ms ±   7.5 ms    [User: 1094.7 ms, System: 1019.1 ms]
  Range (min … max):   324.1 ms … 346.6 ms    10 runs

Result: -33.4ms (-9.1%)

apps/10000

Before

Benchmark 1: node --run build:rolldown
  Time (mean ± σ):      2.459 s ±  0.042 s    [User: 3.858 s, System: 5.627 s]
  Range (min … max):    2.401 s …  2.509 s    10 runs

After

Benchmark 1: node --run build:rolldown
  Time (mean ± σ):      1.744 s ±  0.017 s    [User: 3.300 s, System: 3.796 s]
  Range (min … max):    1.720 s …  1.771 s    10 runs

Result: -0.72s (-29.1%)

Footnotes

  1. https://github.com/gradle/native-platform/issues/203, https://github.com/dotnet/msbuild/issues/2052.

Copy link
Member Author


How to use the Graphite Merge Queue

Add the label merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codecov
Copy link

codecov bot commented Sep 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.90%. Comparing base (9bfd35a) to head (9ade806).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #691   +/-   ##
=======================================
  Coverage   94.90%   94.90%           
=======================================
  Files          12       12           
  Lines        2886     2886           
=======================================
  Hits         2739     2739           
  Misses        147      147           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 12, 2025

CodSpeed Performance Report

Merging #691 will not alter performance

Comparing 09-12-perf_use_getfileattributesexw_for_symlink_metadata_lookup_on_windows (9ade806) with main (9bfd35a)1

Summary

✅ 3 untouched

Footnotes

  1. No successful run was found on main (9ade806) during the generation of this report, so 9bfd35a was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@sapphi-red sapphi-red marked this pull request as ready for review September 12, 2025 06:30
Copy link
Member

Boshen commented Sep 12, 2025

Merge activity

…ws (#691)

[`std::fs::symlink_metadata`](https://doc.rust-lang.org/beta/std/fs/fn.symlink_metadata.html) implementation uses `GetFileInformationByHandle` on Windows, which seems to be known as slow [^1].

This PR adds a function that uses `GetFileAttributesExW` instead of it, which is faster than `GetFileInformationByHandle`.

## Benchmarks

I tested this PR with [rolldown/benchmarks](https://github.com/rolldown/benchmarks). It improved the build time by ~10%
I took the following results with `hyperfine 'node --run build:rolldown'`

### rome
**Before**
```
Benchmark 1: node --run build:rolldown
  Time (mean ± σ):     237.7 ms ±   3.7 ms    [User: 513.1 ms, System: 495.2 ms]
  Range (min … max):   233.1 ms … 243.5 ms    12 runs
```

**After**
```
Benchmark 1: node --run build:rolldown
  Time (mean ± σ):     210.4 ms ±   5.3 ms    [User: 422.1 ms, System: 443.5 ms]
  Range (min … max):   204.1 ms … 223.1 ms    13 runs
```

**Result**: -27.3ms (-11.5%)

### three10x
**Before**
```
Benchmark 1: node --run build:rolldown
  Time (mean ± σ):     367.7 ms ±   5.1 ms    [User: 1313.1 ms, System: 1283.1 ms]
  Range (min … max):   359.7 ms … 374.5 ms    10 runs
```

**After**
```
Benchmark 1: node --run build:rolldown
  Time (mean ± σ):     334.3 ms ±   7.5 ms    [User: 1094.7 ms, System: 1019.1 ms]
  Range (min … max):   324.1 ms … 346.6 ms    10 runs
```

**Result**: -33.4ms (-9.1%)

### apps/10000
**Before**
```
Benchmark 1: node --run build:rolldown
  Time (mean ± σ):      2.459 s ±  0.042 s    [User: 3.858 s, System: 5.627 s]
  Range (min … max):    2.401 s …  2.509 s    10 runs
```

**After**
```
Benchmark 1: node --run build:rolldown
  Time (mean ± σ):      1.744 s ±  0.017 s    [User: 3.300 s, System: 3.796 s]
  Range (min … max):    1.720 s …  1.771 s    10 runs
```

**Result**: -0.72s (-29.1%)

[^1]: gradle/native-platform#203, dotnet/msbuild#2052.
@graphite-app graphite-app bot force-pushed the 09-12-perf_use_getfileattributesexw_for_symlink_metadata_lookup_on_windows branch from 954028f to 9ade806 Compare September 12, 2025 10:38
@graphite-app graphite-app bot merged commit 9ade806 into main Sep 12, 2025
18 checks passed
@graphite-app graphite-app bot deleted the 09-12-perf_use_getfileattributesexw_for_symlink_metadata_lookup_on_windows branch September 12, 2025 10:40
@graphite-app graphite-app bot removed the merge label Sep 12, 2025
@oxc-bot oxc-bot mentioned this pull request Sep 10, 2025
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.

2 participants