Title: Tracking FileSystem provider performance issues · Issue #14497 · PowerShell/PowerShell · GitHub
Open Graph Title: Tracking FileSystem provider performance issues · Issue #14497 · PowerShell/PowerShell
X Title: Tracking FileSystem provider performance issues · Issue #14497 · PowerShell/PowerShell
Description: The IsPathRoot() method does double check for UNC PowerShell/src/System.Management.Automation/namespaces/FileSystemProvider.cs Lines 5026 to 5047 in 281b437 ///
Open Graph Description: The IsPathRoot() method does double check for UNC PowerShell/src/System.Management.Automation/namespaces/FileSystemProvider.cs Lines 5026 to 5047 in 281b437 ///
X Description: The IsPathRoot() method does double check for UNC PowerShell/src/System.Management.Automation/namespaces/FileSystemProvider.cs Lines 5026 to 5047 in 281b437 /// <summary> /// Determines if th...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/14497
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Tracking FileSystem provider performance issues","articleBody":"1. The IsPathRoot() method does double check for UNC\r\nhttps://github.com/PowerShell/PowerShell/blob/281b437a65360ae869d40f3766a1f2bbba786e5e/src/System.Management.Automation/namespaces/FileSystemProvider.cs#L5026-L5047\r\nand could be replaced with more short and fast code. Proposal from @mklement0 https://github.com/PowerShell/PowerShell/issues/14497#issuecomment-751356734\r\n\r\nAlso we need to review GetFileSystemItem(string path, ref bool isContainer, bool showHidden) - there is a root check and maybe a bug (no UNC share check)\r\nhttps://github.com/PowerShell/PowerShell/blob/281b437a65360ae869d40f3766a1f2bbba786e5e/src/System.Management.Automation/namespaces/FileSystemProvider.cs#L1426-L1430\r\n\r\n2. PR #14469 Reduce aggressive correcting casing of file system paths\r\nOn Windows we do case normalizations even if results are not used.\r\n\r\n3. No need to allocate FileInfo and extra strings in IsSameWindowsVolume():\r\nhttps://github.com/PowerShell/PowerShell/blob/281b437a65360ae869d40f3766a1f2bbba786e5e/src/System.Management.Automation/namespaces/FileSystemProvider.cs#L6141-L6147\r\nWe can use `GetDirectoryName(ReadOnlySpan\u003cchar\u003e path)`. Also we should use Ordinal comparison.\r\n\r\n4. EnsureDriveIsRooted() method does extra path.IndexOf(':') - we can simply check last char\r\nhttps://github.com/PowerShell/PowerShell/blob/281b437a65360ae869d40f3766a1f2bbba786e5e/src/System.Management.Automation/namespaces/FileSystemProvider.cs#L5709-L5727\r\n\r\n5. We need to review semantic of IsValidPath() method. If it is exactly about path validity the method could be simplified but we need to measure a performance. In common case it is impossible to validate path by parsing but only by opening.\r\nhttps://github.com/PowerShell/PowerShell/blob/281b437a65360ae869d40f3766a1f2bbba786e5e/src/System.Management.Automation/namespaces/FileSystemProvider.cs#L1192-L1246\r\n\r\n6. Statistic shows:\r\n```powershell\r\ndir -Recurse 'C:\\Program Files (x86)\\' | Select -ExpandProperty Mode | Sort-Object | Group-Object -NoElement\r\n\r\nCount Name\r\n----- ----\r\n 1 -----\r\n 3 --r--\r\n44263 -a---\r\n 6 -ar--\r\n 8136 d----\r\n 3 d---s\r\n 2 d-r--\r\n 1044 la---\r\n```\r\nand we could add \"la---\" as a static element in\r\nhttps://github.com/PowerShell/PowerShell/blob/281b437a65360ae869d40f3766a1f2bbba786e5e/src/System.Management.Automation/namespaces/FileSystemProvider.cs#L2024-L2040\r\n```c#\r\n if (!isLink)\r\n {\r\n // special casing for the common cases - no allocations\r\n switch (fileAttributes)\r\n {\r\n case FileAttributes.Archive:\r\n return \"-a---\";\r\n case FileAttributes.Directory:\r\n return \"d----\";\r\n case FileAttributes.Normal:\r\n return \"-----\";\r\n case FileAttributes.Directory | FileAttributes.ReadOnly:\r\n return \"d-r--\";\r\n case FileAttributes.Archive | FileAttributes.ReadOnly:\r\n return \"-ar--\";\r\n }\r\n }\r\n else if (fileAttributes == FileAttributes.ReadOnly)\r\n {\r\n return \"la---\";\r\n }\r\n\r\n ...\r\n```\r\n\r\n7. Remove double check ItemExists();\r\nhttps://github.com/PowerShell/PowerShell/blob/281b437a65360ae869d40f3766a1f2bbba786e5e/src/System.Management.Automation/namespaces/FileSystemProvider.cs#L6105-L6112","author":{"url":"https://github.com/iSazonov","@type":"Person","name":"iSazonov"},"datePublished":"2020-12-25T07:33:59.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/14497/PowerShell/issues/14497"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5c8b6fc4-fd37-3483-88e2-0405f444abc7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AA60:CD3C9:473F4E:643C37:6A57A868 |
| html-safe-nonce | 4591b11e680f9f04e38b44a99d84461c960b5924e8fe25292119b2b4456cbeb3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTYwOkNEM0M5OjQ3M0Y0RTo2NDNDMzc6NkE1N0E4NjgiLCJ2aXNpdG9yX2lkIjoiMTgzNTExOTAyNjYzOTc3MDY1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b698c49973e974bd376cc60aa34739a3cf0d5bd16bf7deccdaa291d9d3a7a371 |
| hovercard-subject-tag | issue:774664393 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/14497/issue_layout |
| twitter:image | https://opengraph.githubassets.com/63d1354c3c3094e1ce9c220d1edb53cb36319da6fb347e82915c4ad95f1d60a5/PowerShell/PowerShell/issues/14497 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/63d1354c3c3094e1ce9c220d1edb53cb36319da6fb347e82915c4ad95f1d60a5/PowerShell/PowerShell/issues/14497 |
| og:image:alt | The IsPathRoot() method does double check for UNC PowerShell/src/System.Management.Automation/namespaces/FileSystemProvider.cs Lines 5026 to 5047 in 281b437 /// |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | iSazonov |
| hostname | github.com |
| expected-hostname | github.com |
| None | 017a07c29bdd8a37b5907fc9a689338deb7103b5af7f56714193b2700229b3df |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4cd16a676f89d1cedb932671a5c2d20b8e60f86a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width