perf: use GetFileAttributesExW for symlink metadata lookup on Windows#691
Conversation
How to use the Graphite Merge QueueAdd 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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #691 will not alter performanceComparing Summary
Footnotes |
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.
954028f to
9ade806
Compare

std::fs::symlink_metadataimplementation usesGetFileInformationByHandleon Windows, which seems to be known as slow 1.This PR adds a function that uses
GetFileAttributesExWinstead of it, which is faster thanGetFileInformationByHandle.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
After
Result: -27.3ms (-11.5%)
three10x
Before
After
Result: -33.4ms (-9.1%)
apps/10000
Before
After
Result: -0.72s (-29.1%)
Footnotes
https://github.com/gradle/native-platform/issues/203, https://github.com/dotnet/msbuild/issues/2052. ↩