Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module takes over 18 min to install and 5 min to load #134

Closed
ioamnesia opened this issue Mar 13, 2020 · 8 comments
Closed

Module takes over 18 min to install and 5 min to load #134

ioamnesia opened this issue Mar 13, 2020 · 8 comments

Comments

@ioamnesia
Copy link

This module takes ages (understatement) to install and load.
In PS 5.1, install took 18 minutes and load took

c:\users\myuser> install-module microsoft.graph
WARNING: Unable to resolve package source 'https://ci.appveyor.com/nuget/docker-powershell-dev'.

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the
modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y
[1080324.96 ms] C:\Users\myuser> ipmo microsoft.graph
[352021.21 ms] C:\Users\myuser>

In PowerShell 7.0, this module takes 5 minutes to import.

PS>ipmo msonline
[134.54 ms] C:\Users\myuser> ipmo microsoft.graph
[310842.98 ms] C:\Users\myuser>

It also consumes a whopping 1.3gb of RAM when loaded. Just for giggles, I ran [gc]::Collect() and in PS7, RAM usage dropped 400MB. PS5.1 didn't drop much.

What is going on.

@ghost ghost added the ToTriage label Mar 13, 2020
@ghost ghost added this to Issues to triage in Graph SDK - Triage Mar 13, 2020
@darrelmiller
Copy link
Contributor

Microsoft Graph is big surface area. This is a preview and we are working on ways to optimize the size. Perf on PS6/7 is noticeably better.

The Microsoft.Graph module is a metamodule, if there are just parts of Microsoft Graph that you want to access, there are close to 100 smaller modules that you can pull in independently once you have Microsoft.Graph.Authentication installed.

We are rolling out a process to allow us to only update the modules that have been recently updated, so that you should only pay the large install cost once.

We hope to have the module pre-installed in the Azure Cloud Shell image, so there should be no install cost there.

On my Thinkpad X1 Yoga i7 laptop, working from home, I just uninstalled and re-installed and it took just over 2 mins to install completely in PS6. Admittedly, I have a fast internet connection, so that may help. My pwsh.exe instance is showing 184MB of memory usage.

We appreciate your feedback and will continue to make efforts to make the install process as painless as possible.

@darrelmiller darrelmiller removed this from Issues to triage in Graph SDK - Triage Mar 15, 2020
@bergmeister
Copy link

bergmeister commented Apr 6, 2020

The reason why it is faster in PowerShell Core, is because it has newer PowerShellGet and Packagemanagement modules. If you update them, then installation using PowerShell 5.1 should be much faster. With PowerShellGet v3 being developed at the moment, installation speed should generally become much faster. The Graph module could be a bit more pragmatic and reduce the number of modules by merging some, e.g. there are a lot of Microsoft.Graph.Identity.* modules that are probably not worth the maintenance and performance overhead of having so many individual modules.

One of the things that is definitely partly responsible for the bad performancen of the module import is that most Graph modules use a wildcard for FunctionsToExport or CmdletsToExport in their manifest (psd1 file). This would be a low hanging fruit that should improve the import speed. For more details see:
https://github.com/PowerShell/PSScriptAnalyzer/blob/master/RuleDocumentation/UseToExportFieldsInManifest.md

Having said, you shouldn't need to import the root module, just importing the modules that you need should help you in the meantime

@peombwa
Copy link
Member

peombwa commented Dec 18, 2020

Closing this since we are actively working on reducing the SDK size in #428. This should reduce the overall install time.

@peombwa peombwa closed this as completed Dec 18, 2020
@neilmca-inc
Copy link

It's 2023 - I've just had to use the Install-Module cmdlet in Powershell 7 to install the Microsoft.Graph module - selected version 2.1.0 of that module - installation time was 20 minutes - lol

@poi-radvine
Copy link

Here for an update an to get infos about improvements regarding this topic.
I am installing 3 developer pcs and was asking myself, whether it is normal that it takes so long, but at this point Az commands are installed quicker and I reckon that the surface are of az + rm tools is bigger than mg-graph

@mbratukha
Copy link

Tried to install Graph v2.12 - still taking too long

Any update on this topic would be appreciated!

@worldsdream
Copy link

Use PSResourceGet, and you will notice that it will install Microsoft Graph module under 1 minute.

Read more here: https://www.alitajran.com/install-microsoft-powershell-psresourceget-module/

@kyle-rader-msft
Copy link

I'm trying to install Microsoft.Graph 2.18 - and the install still takes minutes, and the Import is also taking minutes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants