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

Consider using module builder pattern to halve module import time #692

Open
bergmeister opened this issue Sep 1, 2019 · 6 comments
Open

Comments

@bergmeister
Copy link
Contributor

Whilst I like posh-git, it also adds a big portion (500-1000ms) to the load time of PowerShell because of the call to Import-Module posh-git in the $PROFILE.
One possibility of halving (I've done an experiment) the module import time, is to have all the source code in one monolithic file instead of dot sourcing them in. This does not mean the source code of the module needs to be stored in a monolithic file but one would need to add a build process before publishing the module, one does not need to re-invent the wheel though as one could e.g. use the ModuleBuilder module for that.
Would you be happy with that?
Or would it be useful to look into alternative ways of having a more lightweight module import (some user's might not use all features, so maybe we could defer some actions?)?

@rkeithhill
Copy link
Collaborator

I don't see a problem with adding a build for the module particularly if it can halve the module import time. As for as "optional" features, that might be tough as this module doesn't offer that much in the way of optional features. That said, I suppose there might be some folks who want only the tab-completion support. Doubt there are many that want only the prompt status and not tab-completion though.

@dahlbyk
Copy link
Owner

dahlbyk commented Sep 11, 2019

but one would need to add a build process before publishing the module, one does not need to re-invent the wheel though as one could e.g. use the ModuleBuilder module for that. Would you be happy with that?

We've discussed elsewhere that a pre-publish build process would be useful in other ways, so I'm not opposed to this as a related optimization. I would want to make sure the module can still be loaded as-is from the Git repo, as many folks use their own fork of the project.

As for as "optional" features, that might be tough as this module doesn't offer that much in the way of optional features. That said, I suppose there might be some folks who want only the tab-completion support. Doubt there are many that want only the prompt status and not tab-completion though.

We could conceivably skip loading all the prompt/status infrastructure if $GitPromptSettings.EnablePromptStatus -eq $false, though technically that setting only disables the Git portion of the prompt, not the rest of it (path, etc).

@bergmeister
Copy link
Contributor Author

Good feedback.
Should I aim to make a PR against the v0 or master branch (or both?). Personally, I still use v0 (accidentally) sometimes because I often forget the -AllowPreRelease switch...

@rkeithhill
Copy link
Collaborator

I'd say master as I'd like to nudge folks towards v1. :-)

@bergmeister
Copy link
Contributor Author

Ok, I've actually opened PRs against both branches. Should we incorporate this into the build as well, by changing the src folder in the test line below to the built module in the out folder?
https://github.com/dahlbyk/posh-git/blob/master/test/Shared.ps1#L1

@rkeithhill
Copy link
Collaborator

rkeithhill commented Sep 15, 2019

I'd rather not change that line to always point to the release dir because my typical dev flow is to run Pester tests while I'm doing dev work (not having built). Maybe we can change that line to look for a variable like $PoshModuleToTest. When that variable is not found, we use the current path (to the src dir). The build script could define this variable and set it to the release dir location, and then run the Pester tests.

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

3 participants