GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Avoid extra SMB queries when formatting file names by daxian-dbw · Pull Request #28038 · PowerShell/PowerShell

Conversation

@daxian-dbw

@daxian-dbw Dongbo Wang (daxian-dbw) commented Sep 21, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

PR Summary

  • Check cached file attributes before inspecting detailed reparse-point metadata in NameString.
  • Avoid one FindFirstFile query per ordinary item when formatting directory listings, which is particularly expensive on SMB shares.
  • Add a regression test proving that cached non-reparse metadata avoids reopening the path.

PR Context

Fixes #27088.

IsReparsePointLikeSymlink must inspect the reparse tag to distinguish symbolic links and junctions from cloud-drive placeholders. Default formatting previously invoked that expensive check for every item, including ordinary non-links. NameString now uses the already-populated Attributes metadata to short-circuit ordinary items while preserving detailed classification for actual reparse points.

Benchmark

Measured 4,897 entries over the local UNC path \\localhost\c$\Windows\System32. Each result is the median of three warmed-up runs.

Measurement PowerShell 7.6.6 without fix Fixed debug build Improvement
NameString 3,870 ms 81 ms 48x faster
Default formatting 4,250 ms 727 ms 5.8x faster

A same-binary control using the fixed debug build isolates the avoided operation:

Operation Median
Guarded NameString 81 ms
Direct unconditional IsReparsePointLikeSymlink probe 3,939 ms

This confirms that the approximately 3.9-second cost came from calling FindFirstFile once per item. Absolute formatting times vary between release and debug builds, but the per-item SMB query is eliminated.

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge. If this PR is a work in progress, please open this as a Draft Pull Request and mark it as Ready to Review when it is ready to merge.
  • Breaking changes
    • None
    • OR
    • Experimental feature(s) needed
      • Experimental feature name(s):
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed
      • Issue filed:
  • Testing - New and feature
    • N/A or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rkeithhill reacted with hooray emoji
All reactions
  • 🎉 1 reaction
@daxian-dbw
Avoid extra network query when formatting file names
94ca3ac
Co-authored-by: Copilot App <[email protected]>
@daxian-dbw
Dongbo Wang (daxian-dbw) requested a review from a team as a code owner September 21, 2026 20:58
Copilot AI lite review requested due to automatic review settings September 21, 2026 20:58
@azure-pipelines

azure-pipelines Bot commented Sep 21, 2026

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot started reviewing on behalf of Dongbo Wang (daxian-dbw) September 21, 2026 20:59
View session
@daxian-dbw Dongbo Wang (daxian-dbw) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Sep 21, 2026
Copilot AI reviewed Sep 21, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

No unresolved review issues were identified, and regression coverage was added.

Review effort: Lite
Findings: None

What changed in this PR

Improves file-name formatting performance by avoiding unnecessary SMB metadata queries for ordinary items.

Changes:

  • Uses cached attributes to short-circuit reparse-point inspection.
  • Adds regression coverage for cached metadata behavior.
File Description
test/​powershell/​Modules/​Microsoft.PowerShell.Management/​Get-Item.Tests.ps1 Verifies cached non-reparse items do not reopen their paths.
src/​System.Management.Automation/​namespaces/​FileSystemProvider.cs Avoids unnecessary metadata queries during formatting.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Review - Needed The PR is being reviewed label Sep 29, 2026
@microsoft-github-policy-service

microsoft-github-policy-service Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jshigetomi
Justin Chung (jshigetomi) approved these changes Oct 8, 2026
View reviewed changes

@jshigetomi Justin Chung (jshigetomi) left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Reviewed the cached-attribute guard, reparse-point handling, and regression coverage. Looks good to me.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
iSazonov
Ilya (iSazonov) reviewed Oct 9, 2026
View reviewed changes
Comment thread src/System.Management.Automation/namespaces/FileSystemProvider.cs
// Checking the cached attributes first avoids an extra filesystem query for every non-link,
// which is particularly expensive when formatting items on an SMB share.
if (InternalSymbolicLinkLinkCodeMethods.IsReparsePoint(fileInfo)
&& InternalSymbolicLinkLinkCodeMethods.IsReparsePointLikeSymlink(fileInfo))

@iSazonov Ilya (iSazonov) Oct 9, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The IsReparsePointLikeSymlink method is used in RemoveDirectoryInfoItem(), so I guess it makes sense to insert this check there too.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@daxian-dbw Dongbo Wang (daxian-dbw) Oct 9, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

That's out of scope for this PR. This PR is only for fixing the formatting.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit c4ae347 into PowerShell:master Oct 9, 2026
48 of 51 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@daxian-dbw
Dongbo Wang (daxian-dbw) deleted the daxian-dbw-investigate-network-dir-formatting branch October 9, 2026 16:35
@daxian-dbw Dongbo Wang (daxian-dbw) removed the Review - Needed The PR is being reviewed label Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iSazonov Ilya (iSazonov) iSazonov left review comments
Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@jshigetomi Justin Chung (jshigetomi) jshigetomi approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

PS 7.6 - extremly slow output of dir on network drive

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@daxian-dbw @iSazonov @jshigetomi
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.