Skip to content

Conversation

@iSazonov
Copy link
Collaborator

@iSazonov iSazonov commented Dec 20, 2020

PR Summary

Fix #12795

While modern (SSD) disks are fast, this does not mean that disk operations have become so insignificant that they can be neglected. For case correction we use additional disk operations (enumerations).

It is very weird that we do case corrections for file paths which are excluded in the PR:

  • on Linux
  • for operations without output like IsItemContainer()

PR Context

#9250 Return correct casing of filesystem path during normalization

PR Checklist

@iSazonov iSazonov added the CL-Performance Indicates that a PR should be marked as a performance improvement in the Change Log label Dec 20, 2020
@iSazonov iSazonov requested a review from anmenaga as a code owner December 20, 2020 18:29
@xavierd
Copy link

xavierd commented Dec 21, 2020

I'm wondering if this would also help to fix #13432.

@iSazonov
Copy link
Collaborator Author

I'm wondering if this would also help to fix #13432.

@xavierd I hope. I replaced full enumeration with getting first element from IEnumerable. Could you please download compiled artifact from the PR and analyze PerfView traces to confirm.

@ghost ghost added the Review - Needed The PR is being reviewed label Dec 28, 2020
@ghost
Copy link

ghost commented Dec 28, 2020

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

@iSazonov iSazonov closed this May 20, 2021
@ghost ghost removed the Review - Needed The PR is being reviewed label May 20, 2021
@iSazonov iSazonov reopened this May 20, 2021
Comment on lines +127 to +130
if (Platform.IsLinux)
{
return path;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Aren't MacOS paths also case sensitive? Is there another reason we'd have this behaviour for Linux but not MacOS?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

By default MacOS uses a case-insensitive file system.

Copy link
Member

Choose a reason for hiding this comment

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

The primary scenario where we hit a problem is with git where the remote repo is on Linux and case-sensitive and someone adds a file with a directory that they manually typed and then you have two directories in git that only differ by case. I think that affects Windows and macOS clients even if their local filesystems are case insensitive.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If git is case-sensetive locally on all platforms then users should follow the application design why should PowerShell do expensive work for all paths and for other scenarios?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

they manually typed

the remote repo is on Linux and case-sensitive

Wow! If repo/application is case-sensitive and user obviously know this shouldn't the user take care of compliance himself?

If different platforms have different behavior, this is a fundamental and unsolvable problem. We constantly get requests about slashes because they are different in local (Windows) and remote session (Linux). I haven't seen as many requests about case, but the root of the problem is the same.
It should be clearly written in the documentation that this is the user's concern: if a scenario is - scripts works on Windows client and remote sessions are on Linux-s (and vise-versa) a recommendation for users should be to prefer forward slashes (backslashs) and be careful about cases.

private FileSystemInfo GetFileSystemItem(string path, ref bool isContainer, bool showHidden)
{
path = NormalizePath(path);
path = GetCorrectCasedPath(path);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see we've swapped a bunch of calls to use GetCorrectCasedPath -- are there cases where NormalizePath is still called on its own? Or is it only used in the GetCorrectCasedPath method now?

Copy link
Collaborator Author

@iSazonov iSazonov May 21, 2021

Choose a reason for hiding this comment

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

After the PR:

  • GetCorrectCasedPath - 16 uses.
  • NormalizePath - 8 uses.

The PR does mostly obvious changes. Later we could remove more GetCorrectCasedPath uses.

@ghost ghost added the Review - Needed The PR is being reviewed label May 28, 2021
@ghost
Copy link

ghost commented May 28, 2021

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

@SteveL-MSFT SteveL-MSFT added the WG-Engine-Providers built-in PowerShell providers such as FileSystem, Certificates, Registry, etc. label Aug 6, 2021
@JamesWTruher
Copy link
Collaborator

While the WG agrees that something might be done, we have an overriding concern for compatibility and being comprehensive in the light that some unix file systems may be case insensitive. We have decided to reject this PR for the following reasons:

  • high level of risk due to complexity in current code base
  • we need to have expected behavior well documented
  • we need to have proper, comprehensive validation for new behaviors

@iSazonov
Copy link
Collaborator Author

While the WG agrees that something might be done, we have an overriding concern for compatibility and being comprehensive in the light that some unix file systems may be case insensitive. We have decided to reject this PR for the following reasons:

  • high level of risk due to complexity in current code base
  • we need to have expected behavior well documented
  • we need to have proper, comprehensive validation for new behaviors

Interesting! :-) Could please the WG point me RFC, public discussion and important business scenarios for adding the feature? Did the WG explicitly measure and approve 5x, 10x and more extra P/Invokes for every path in processing? Is the opinion of the WG unapologetically strict that the main thing is that I should see in the console once a day "Abc" instead of "abc", although I do not care about it and I need my scripts run every minute to work as fast as possible?

@ghost ghost removed the Review - Needed The PR is being reviewed label Aug 24, 2021
@ghost ghost added the Review - Needed The PR is being reviewed label Aug 31, 2021
@ghost
Copy link

ghost commented Aug 31, 2021

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

@daxian-dbw daxian-dbw removed the Review - Needed The PR is being reviewed label Nov 2, 2021
@daxian-dbw
Copy link
Member

Given that the engine WG has rejected this PR, I will close it for housekeeping purpose.

@daxian-dbw daxian-dbw closed this Nov 2, 2021
@iSazonov
Copy link
Collaborator Author

iSazonov commented Nov 2, 2021

I can't agree with that. It makes absolutely no sense to do this in scripts. For cosmetic effect we make file operations slow. PowerShell is already bad with files and this makes it unusable at all. Of course this is not a problem if you just type cd /var/log, but I have to say goodbye to PowerShell every time for large disks.
It's a shame that PowerShell remains a toy not suitable for serious work in a corporate environment.

@mi-hol
Copy link

mi-hol commented Dec 1, 2021

@SteveL-MSFT As a consequence of this WG decision the slogan "PowerShell for every system!" should be removed from github´s About page!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Performance Indicates that a PR should be marked as a performance improvement in the Change Log WG-Engine-Providers built-in PowerShell providers such as FileSystem, Certificates, Registry, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PS7: Get-Item and Get-ChildItem slow on UNC paths because it enumerates parent directories

7 participants