Skip to content

Fix #16929 do not show profile load time msg with new pwsh parameter #17535

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

Conversation

rkeithhill
Copy link
Collaborator

This PR adds a new pwsh command line parameter to enable the display of the profile load time message.

PR Summary

Changes the host to not display the profile load time by default. A new pwsh command line switch -ShowProfileLoadTime was added to allow someone to show the profile load time regardless of the length of the load time.

Usage: pwsh[.exe] [-Login] [[-File] <filePath> [args]]
                  [-Command { - | <script-block> [-args <arg-array>]
                                | <string> [<CommandParameters>] } ]
                  [-ConfigurationName <string>] [-CustomPipeName <string>]
                  [-EncodedCommand <Base64EncodedCommand>]
                  [-ExecutionPolicy <ExecutionPolicy>] [-InputFormat {Text | XML}]
                  [-Interactive] [-MTA] [-NoExit] [-NoLogo] [-NonInteractive] [-NoProfile]
                  [-OutputFormat {Text | XML}] [-SettingsFile <filePath>] [-ShowProfileLoadTime]
                  [-SSHServerMode] [-STA] [-Version] [-WindowStyle <style>]
                  [-WorkingDirectory <directoryPath>]

       pwsh[.exe] -h | -Help | -? | /?
       
...

-ShowProfileLoadTime

    Displays the time taken to load the PowerShell profiles.

-SSHServerMode | -sshs

PR Context

Addresses #16929 to further reduce the amount of default startup banner text.

PR Checklist

This PR adds a new pwsh command line parameter to enable display of the
profile load time message.
@SteveL-MSFT
Copy link
Member

I believe the original intent of showing the load time was all the complaints from users about how long it was taking PowerShell to startup when most of the time was in their profile. If this is not enabled by default, I can't imagine anyone taking the time to enable this. I wonder if it makes more sense to have this opt-out rather than opt-in? -DisableProfileLoadTime.

@daxian-dbw daxian-dbw added the WG-Interactive-Console the console experience label Jun 21, 2022
@rkeithhill
Copy link
Collaborator Author

@SteveL-MSFT I implemented this based on my interpretation of this WG comment: #16929 (comment)

That said, I'm fine with making the default be enabled and having a switch to disable it. But I would like to get @theJasonHelmick's feedback to make sure this is still in line with the thoughts of the WG.

@ghost ghost added the Review - Needed The PR is being reviewed label Jun 29, 2022
@ghost
Copy link

ghost commented Jun 29, 2022

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

@rkeithhill
Copy link
Collaborator Author

FYI I have re-implemented this as an opt-out parameter -DisableProfileLoadTime. Unfortunately, this approach does not lend itself to unit testing.

@theJasonHelmick
Copy link
Collaborator

@SteveL-MSFT I implemented this based on my interpretation of this WG comment: #16929 (comment)

That said, I'm fine with making the default be enabled and having a switch to disable it. But I would like to get @theJasonHelmick's feedback to make sure this is still in line with the thoughts of the WG.

@rkeithhill -- I agree with Steve -- and thank you so much for this work!

@daxian-dbw
Copy link
Member

@rkeithhill The Console-Interactive WG reviewed this PR and we agree to have it opt-out rather than opt-in. So, by default, the existing behavior is not changed.

Then the ask becomes to have a new switch to hide the profile load time. However, the -nologo switch already hides the profile load time, which makes having a new switch just for that seem to be an overkill ...
@rkeithhill what's your thoughts about this?

@ghost ghost removed the Review - Needed The PR is being reviewed label Jul 11, 2022
@rkeithhill
Copy link
Collaborator Author

The difference with -NoLogo is that you don't see anything displayed in the console until after all profiles are processed. Where you typically want this feature is when your profile always takes several seconds to process and seeing the profile load time message every single session start is just, well, annoying. Also, I prefer seeing which version of PowerShell I'm running which you lose with -NoLogo. My preference would be to add an opt-out parameter. I have it currently implemented with @SteveL-MSFT's suggested name -DisableProfileLoadTime but I wonder if -NoProfileLoadTime would be better (shorter and more consistent with -NoLogo)?

@SteveL-MSFT
Copy link
Member

I agree that -NoLogo suppresses everything whereas you may want the PowerShell version. -NoProfileLoadTime seems fine to me.

@daxian-dbw
Copy link
Member

Alright, @rkeithhill can you update this PR then? It's still the showprofileloadtime implementation.

@rkeithhill rkeithhill force-pushed the rkeithhill/add-cmdline-param-to-show-profileloadtime-msg branch from a193fcd to 0df6355 Compare July 13, 2022 04:27
@pull-request-quantifier-deprecated

This PR has 21 quantified lines of changes. In general, a change size of upto 200 lines is ideal for the best PR experience!


Quantification details

Label      : Extra Small
Size       : +18 -3
Percentile : 8.4%

Total files changed: 3

Change summary by file extension:
.cs : +11 -1
.resx : +7 -2

Change counts above are quantified counts, based on the PullRequestQuantifier customizations.

Why proper sizing of changes matters

Optimal pull request sizes drive a better predictable PR flow as they strike a
balance between between PR complexity and PR review overhead. PRs within the
optimal size (typical small, or medium sized PRs) mean:

  • Fast and predictable releases to production:
    • Optimal size changes are more likely to be reviewed faster with fewer
      iterations.
    • Similarity in low PR complexity drives similar review times.
  • Review quality is likely higher as complexity is lower:
    • Bugs are more likely to be detected.
    • Code inconsistencies are more likely to be detetcted.
  • Knowledge sharing is improved within the participants:
    • Small portions can be assimilated better.
  • Better engineering practices are exercised:
    • Solving big problems by dividing them in well contained, smaller problems.
    • Exercising separation of concerns within the code changes.

What can I do to optimize my changes

  • Use the PullRequestQuantifier to quantify your PR accurately
    • Create a context profile for your repo using the context generator
    • Exclude files that are not necessary to be reviewed or do not increase the review complexity. Example: Autogenerated code, docs, project IDE setting files, binaries, etc. Check out the Excluded section from your prquantifier.yaml context profile.
    • Understand your typical change complexity, drive towards the desired complexity by adjusting the label mapping in your prquantifier.yaml context profile.
    • Only use the labels that matter to you, see context specification to customize your prquantifier.yaml context profile.
  • Change your engineering behaviors
    • For PRs that fall outside of the desired spectrum, review the details and check if:
      • Your PR could be split in smaller, self-contained PRs instead
      • Your PR only solves one particular issue. (For example, don't refactor and code new features in the same PR).

How to interpret the change counts in git diff output

  • One line was added: +1 -0
  • One line was deleted: +0 -1
  • One line was modified: +1 -1 (git diff doesn't know about modified, it will
    interpret that line like one addition plus one deletion)
  • Change percentiles: Change characteristics (addition, deletion, modification)
    of this PR in relation to all other PRs within the repository.


Was this comment helpful? 👍  :ok_hand:  :thumbsdown: (Email)
Customize PullRequestQuantifier for this repository.

@rkeithhill
Copy link
Collaborator Author

One unfortunate consequence of using an opt-out parameter is that it doesn't lend itself to testing. From what I can see, the tests in ConsoleHost.Tests.ps1 all specify starting pwsh with -NoProfile. That makes sense. You wouldn't want to process a dev's profile when running console host tests.

@rkeithhill
Copy link
Collaborator Author

BTW I did update this PR to be opt-out. It's ready for review again.

@iSazonov iSazonov added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Jul 16, 2022
@rkeithhill rkeithhill changed the title Fix #16929 do not show profile load time msg by default Fix #16929 do not show profile load time msg with new pwsh parameter Jul 16, 2022
@rkeithhill
Copy link
Collaborator Author

Here's the updated usage:

Usage: pwsh[.exe] [-Login] [[-File] <filePath> [args]]
                  [-Command { - | <script-block> [-args <arg-array>]
                                | <string> [<CommandParameters>] } ]
                  [-ConfigurationName <string>] [-CustomPipeName <string>]
                  [-EncodedCommand <Base64EncodedCommand>]
                  [-ExecutionPolicy <ExecutionPolicy>] [-InputFormat {Text | XML}]
                  [-Interactive] [-MTA] [-NoExit] [-NoLogo] [-NonInteractive] [-NoProfile]
                  [-NoProfileLoadTime] [-OutputFormat {Text | XML}]
                  [-SettingsFile <filePath>] [-SSHServerMode] [-STA]
                  [-Version] [-WindowStyle <style>]
                  [-WorkingDirectory <directoryPath>]

       pwsh[.exe] -h | -Help | -? | /?
  
  ...
  
  -NoLogo | -nol

    Hides the banner text at startup of interactive sessions.

...

-NoProfile | -nop

    Does not load the PowerShell profiles.

-NoProfileLoadTime

    Hides the PowerShell profile load time text shown at startup when the load
    time exceeds 500 milliseconds.

@@ -920,6 +931,11 @@ private void ParseHelper(string[] args)
_sshServerMode = true;
ParametersUsed |= ParameterBitmap.SSHServerMode;
}
else if (MatchSwitch(switchKey, "noprofileloadtime", "noprofileloadtime"))
Copy link
Member

Choose a reason for hiding this comment

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

Should we consider having -nplt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I like that. But how about -noplt so the alias is a bit more consistent with the other -no aliases: -nol, -nop, -noni?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nevermind, when I try that I run smack into this dbg assert:

Dbg.Assert(match.Contains(smallestUnambiguousMatch), "sUM should be a substring of match");

Copy link
Member

@SteveL-MSFT SteveL-MSFT left a comment

Choose a reason for hiding this comment

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

One non-blocking suggestion

@PaulHigin PaulHigin merged commit b6a6190 into PowerShell:master Jul 19, 2022
@ghost
Copy link

ghost commented Aug 12, 2022

🎉v7.3.0-preview.7 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Extra Small WG-Interactive-Console the console experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants