Title: The module analysis cache is never saved by short-lived pwsh processes · Issue #28375 · PowerShell/PowerShell · GitHub
Open Graph Title: The module analysis cache is never saved by short-lived pwsh processes · Issue #28375 · PowerShell/PowerShell
X Title: The module analysis cache is never saved by short-lived pwsh processes · Issue #28375 · PowerShell/PowerShell
Description: Summary of the new feature / enhancement When a command is auto-loaded, PowerShell analyzes the modules on PSModulePath and caches the result in ModuleAnalysisCache-
Open Graph Description: Summary of the new feature / enhancement When a command is auto-loaded, PowerShell analyzes the modules on PSModulePath and caches the result in ModuleAnalysisCache-
X Description: Summary of the new feature / enhancement When a command is auto-loaded, PowerShell analyzes the modules on PSModulePath and caches the result in ModuleAnalysisCache-<hash>. The cache is writt...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/28375
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"The module analysis cache is never saved by short-lived pwsh processes","articleBody":"### Summary of the new feature / enhancement\n\nWhen a command is auto-loaded, PowerShell analyzes the modules on PSModulePath and caches the result in `ModuleAnalysisCache-\u003chash>`. The cache is written by a background task that waits 10 seconds and then until nothing has changed for 3 more seconds (`AnalysisCacheData.QueueSerialization`). A pwsh that runs one command and exits sooner, which is how scripts, build tools and agents use `pwsh -Command` / `pwsh -File`, never writes it. Every such process analyzes the same modules again.\n\nOn my machine the copy of 7.6.9 I used for testing had no cache file at all after hundreds of runs. With a cache pre-written by a longer session (`PSModuleAnalysisCachePath`), `pwsh -NoProfile -NonInteractive -Command \"Get-ChildItem -Name src | Select-Object -First 5\"` is 150 ms faster on Windows 11 (621 -> 471 ms, 95% CI 140-180) and 76 ms faster on Ubuntu 26.04 under WSL2 on the same machine (388 -> 303 ms, CI 62-97), 30 interleaved runs each. On Windows the user module path is under OneDrive (Documents redirection) and is searched first, so a few user modules (AzureAD alone 32 ms) are analyzed before the core module that has Get-ChildItem is reached.\n\n### Proposed technical implementation details (optional)\n\nIf a save is still pending when the process exits, write the cache synchronously from a ProcessExit handler. I have a change that does this (about 20 lines in AnalysisCache.cs plus a Pester test) and can open a PR.\n","author":{"url":"https://github.com/azchohfi","@type":"Person","name":"azchohfi"},"datePublished":"2026-11-07T04:51:39Z","url":"https://github.com/PowerShell/PowerShell/issues/28375"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:fa16bd53-ad6d-7d0a-6c00-0ab2b231a9d0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8C6C:3C6B7D:1C056C:24F56C:6AFD0125 |
| html-safe-nonce | bce0eeabf1a963072855653f4192e50c1ab7ad425442828deb154c14fa9686d9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzZDOjNDNkI3RDoxQzA1NkM6MjRGNTZDOjZBRkQwMTI1IiwidmlzaXRvcl9pZCI6IjQ0Nzg5NzEzNDYwOTIzNTk5NzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 36b2ee3608bbd3bd60f630d253439e55ea18db9a1ca40815d7e2cb3f0351e359 |
| hovercard-subject-tag | issue:6255306149 |
| 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/28375/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6b2adaf30481329837cb5e9695d5a58bffedbb20da1240ebdb046cba4c52a7f8/PowerShell/PowerShell/issues/28375 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6b2adaf30481329837cb5e9695d5a58bffedbb20da1240ebdb046cba4c52a7f8/PowerShell/PowerShell/issues/28375 |
| og:image:alt | Summary of the new feature / enhancement When a command is auto-loaded, PowerShell analyzes the modules on PSModulePath and caches the result in ModuleAnalysisCache- |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | azchohfi |
| hostname | github.com |
| expected-hostname | github.com |
| None | cfabad6ee26d2b84c7afef4ae0cc71b8b692fb9d66f9f15997652ef991bfd3f4 |
| 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 | 35f85b78676038389558a41adf8d76e474592ede |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width