You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Is hardlinks really that important that they need to be in the Mode for fileinfo? #8051
Committee-ReviewedPS-Committee has reviewed this and made a decisionIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.WG-Engine-Performancecore PowerShell engine, interpreter, and runtime performance
I guess windows only.
The slowness comes from having to reopen each file to get the hardlink count. The rest of the information is available in the FileInfo object.
For the hardlink, we need to call CreateFile (slow) to get a handle, and then use it to get the handle info (fast).
cmd.exe doesn't do this. It shows link types when there is a reparse-point. We could display when there is a reparse point, and ignore hardlinks.
cmd.exe doesn't do this. It shows link types when there is a reparse-point. We could display when there is a reparse point, and ignore hardlinks.
IIRC a hard link isn't set as a reparse point so having a check on that won't work. I'm unsure as to the speed but you can use FindFirstFileName and FindNextFileName to enumerate all hard links on a file without calling CreateFile. As for what that does internally I have no idea.
The problem is the extra roundtrips to disc, since we don't get enough information from the FileInfo. And going from a FileInfo to a filehandle, which is needed to get the the hardlink count, is expensive on windows.
I argue that this info is so rarely needed that paying the price all the time is not motivated.
Here's some pointers to the relevant docs for people interested in looking deeper:
Ilya (@iSazonov) I'm not that concerned about the LinkType as it isn't displayed by default.
I'm starting to think that the right solution is just to change the default formatting. We can keep the current as a non-default view.
Get-ChildItem's -Force flag is primarily for displaying hidden or system files. I'd be inclined to think... probably not. I believe there was discussion of a separate switch to enable querying this information?
@PowerShell/powershell-committee reviewed this and is ok with not having hardlinks in the default view, consider having a different view that would provide it
I agree with Ilya (@iSazonov) on a seperate switch like -IncludeHardLinks or a generic -IncludeLinks since it also needs to adjust the Process Token Privilege on Windows to get the proper LinkType and Target info, per invocation. See #7127
Committee-ReviewedPS-Committee has reviewed this and made a decisionIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.WG-Engine-Performancecore PowerShell engine, interpreter, and runtime performance
Activity
iSazonov commentedon Oct 17, 2018
Do p/invoke so slow? On Windows only or on Unix-s too?
powercode commentedon Oct 17, 2018
I guess windows only.
The slowness comes from having to reopen each file to get the hardlink count. The rest of the information is available in the FileInfo object.
For the hardlink, we need to call
CreateFile(slow) to get a handle, and then use it to get the handle info (fast).cmd.exe doesn't do this. It shows link types when there is a reparse-point. We could display when there is a reparse point, and ignore hardlinks.
iSazonov commentedon Oct 17, 2018
I wonder that is so slow. In the topic I see " In testing, it slowed down our processing from 240ms for 21000 files, to 750ms. "
iSazonov commentedon Oct 17, 2018
Agree. But it looks as a breaking change and also we need a way to expose the information by demand (new switch?)
powercode commentedon Oct 17, 2018
I'm not sure it is a breaking change. If I recall correctly, formatting is explicitly not a part of the public contract.
jborean93 commentedon Oct 17, 2018
IIRC a hard link isn't set as a reparse point so having a check on that won't work. I'm unsure as to the speed but you can use FindFirstFileName and FindNextFileName to enumerate all hard links on a file without calling
CreateFile. As for what that does internally I have no idea.iSazonov commentedon Oct 18, 2018
Seems two fields is affected - LinkType and Mode.
powercode commentedon Oct 18, 2018
The problem is the extra roundtrips to disc, since we don't get enough information from the FileInfo. And going from a FileInfo to a filehandle, which is needed to get the the hardlink count, is expensive on windows.
I argue that this info is so rarely needed that paying the price all the time is not motivated.
Here's some pointers to the relevant docs for people interested in looking deeper:
powercode commentedon Oct 18, 2018
Ilya (@iSazonov) I'm not that concerned about the LinkType as it isn't displayed by default.
I'm starting to think that the right solution is just to change the default formatting. We can keep the current as a non-default view.
iSazonov commentedon Oct 18, 2018
Staffan Gustafsson (@powercode) Remove mode from default view? I'd vote to follow cmd.exe behavior (exclude hardlynk from the mode)
powercode commentedon Oct 18, 2018
I'm fine with that too.
iSazonov commentedon Oct 18, 2018
Steve Lee (@SteveL-MSFT) Can you confirm the change?
rkeithhill commentedon Oct 18, 2018
Will
-Force"force" the display of this info? I do have some hardlinks that I'd link to see what they're targeting.vexx32 commentedon Oct 18, 2018
Get-ChildItem's
-Forceflag is primarily for displaying hidden or system files. I'd be inclined to think... probably not. I believe there was discussion of a separate switch to enable querying this information?iSazonov commentedon Oct 19, 2018
I'd consider -IncludeHardLinks for Get-Item and Get-ChildrenItem.
SteveL-MSFT commentedon Oct 19, 2018
I would be ok with removing hardlinks by default. A dynamic param for FileSystemProvider may be an ok solution.
SteveL-MSFT commentedon Oct 24, 2018
@PowerShell/powershell-committee reviewed this and is ok with not having hardlinks in the default view, consider having a different view that would provide it
henrivdr commentedon Sep 30, 2019
I agree with Ilya (@iSazonov) on a seperate switch like -IncludeHardLinks or a generic -IncludeLinks since it also needs to adjust the Process Token Privilege on Windows to get the proper LinkType and Target info, per invocation. See #7127
SteveL-MSFT commentedon Sep 30, 2019
This is already fixed by #8789