rust-lang / rust-lang/rust

Using `GetFileInformationByName` in Windows for file stat/metadata operations

Open
#130,169 0 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-filesystem C-optimization I-slow O-windows T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Continuing discussion from https://github.com/rust-lang/rust/pull/128256...

Currently, window's fs.rs uses the GetFileInformationByHandle api which requires opening and closing a file handle. A new API will be available in future builds of Windows (from documentation it should be around 24H2/26052) called GetFileInformationByName which does not require opening a file handle. This reduces 2-3 syscalls in this code path which can have a reasonable performance gain.

There are a few design considerations however,

  • Not all file-system drivers support this API, for example FAT32
  • Backwards compatibility stops at 1709, i.e. (basically this feature would be #[cfg(not(target_vendor = "win7")] )

Currently, this change would support tier-1 support for https://github.com/rust-lang/rust/issues/121478 since it includes all the fields needed in one call. In addition to removing the additional syscall for handling reparse points.

Prior Art:

Links:

cc: @ChrisDenton

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Windows fs.rs and read the discussion in PR 128256, then compare the libuv and CPython prior art and the Windows API documentation linked in the issue. The work is complete when file stat/metadata operations use GetFileInformationByName where supported while preserving compatibility for older Windows builds and file-system drivers that lack the API.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.