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

Optimizations for improving speed #2825

Open
wants to merge 62 commits into
base: master
Choose a base branch
from

Conversation

daxgames
Copy link
Member

@daxgames daxgames commented Feb 11, 2023

Optimize for Speed of Launch for Cmd.exe sessions.

  • Removed duplicate path entry prevention, aka enhance_path functionality from %cmder_root%\vendor\init.bat.

  • %cmder_root%\vendor\init.bat is now a run once thing that generates %cmder_root%\config\user_init.cmd.

  • %cmder_root%\config\user_init.cmd :

    • Is generated from a template, %cmder_root%\vendor\user_init.cmd.template, if it does not exist.

      • Is owned by the end user to edit however necessary.
      • Can be re-generated by:
        • Deleting the current output file and starting a new cmd::Cmder session.

        • Running a powershell script:

          image

    • Is 3+ times faster than the current master branch %cmder_root%\vendor\init.bat

    • Is esentially hardcoded version of init.bat that does everything init.bat does minus autodiscovery of MOST config.

      • It still recursively updates the path if /max_depth command line arg is greater than 1.
  • The below speeds are WITHOUT /f with /t on a virtual box vm running on an older laptop without SSD storage. Modern hardware SHOULD be even faster

  • master --------------------------> more_speed_2 - Initial Run------------------------------------> After user_init.cmd

    image

@daxgames daxgames marked this pull request as draft February 12, 2023 13:11
@daxgames daxgames marked this pull request as ready for review February 12, 2023 23:10
@i-s-o
Copy link

i-s-o commented Feb 19, 2023

I'm not sure if this is the best place to report this, here it goes.

When I run Cmder with this PR in a clean system (Windows Sandbox), I get an error on the invocation of powershell -f %cmder_root%\vendor\bin\create-cmdercfg.ps1, see below:

Initial run

 9:55:00.98 DEBUG(init.bat): Env Var - CMDER_ROOT=C:\tools\cmder-1464

 9:55:00.99 DEBUG(init.bat): Env Var - debug_output=1

Generating Clink initial settings in "C:\tools\cmder-1464\config\clink_settings"
        1 file(s) copied.
Additional *.lua files in "C:\tools\cmder-1464\config" are loaded on startup.
Creating Cmder prompt config file: "C:\tools\cmder-1464\config\cmder_prompt_config.lua"
        1 file(s) copied.
 9:55:01.13 DEBUG(init.bat): Looking for Git install root...

 9:55:01.18 DEBUG(:read_version): Env Var - git_executable=C:\tools\cmder-1464\vendor\git-for-windows\cmd\git.exe

 9:55:01.37 DEBUG(:read_version): Env Var - GIT_VERSION_VENDORED=2.39.0.windows.2

 9:55:01.45 DEBUG(:validate_version): ARGV[1]=VENDORED, ARGV[2]=2.39.0.windows.2

 9:55:01.48 DEBUG(:parse_version): ARGV[1]=VENDORED, ARGV[2]=2.39.0.windows.2

 9:55:01.52 DEBUG(:validate_version): Found Git Version for VENDORED: 2.39.0.windows.2

 9:55:01.77 DEBUG(init.bat): Using vendored Git '2.39.0.windows.2'...

 9:55:01.79 DEBUG(init.bat): Using Git from 'C:\tools\cmder-1464\vendor\git-for-windows...

 9:55:01.82 DEBUG(init.bat): START - git.exe(prepend): Env Var - PATH=C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;

 9:55:01.87 DEBUG(init.bat): END - git.exe(prepend): Env Var - PATH=C:\tools\cmder-1464\vendor\git-for-windows\cmd;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;

 9:55:01.92 DEBUG(init.bat): START - nix_tools(append): Env Var - PATH=C:\tools\cmder-1464\vendor\git-for-windows\cmd;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;

 9:55:01.95 DEBUG(init.bat): END - nix_tools(append): Env Var - PATH=C:\tools\cmder-1464\vendor\git-for-windows\cmd;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;;C:\tools\cmder-1464\vendor\git-for-windows\usr\bin

 9:55:02.10 DEBUG(init.bat): Found Git in: 'GIT_INSTALL_ROOT=C:\tools\cmder-1464\vendor\git-for-windows'

 9:55:02.12 DEBUG(init.bat): START - vendor/bin(prepend): Env Var - PATH=C:\tools\cmder-1464\vendor\git-for-windows\cmd;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;;C:\tools\cmder-1464\vendor\git-for-windows\usr\bin

 9:55:02.15 DEBUG(init.bat): END - vendor/bin(prepend): Env Var - PATH=C:\tools\cmder-1464\vendor\bin;C:\tools\cmder-1464\vendor\git-for-windows\cmd;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;;C:\tools\cmder-1464\vendor\git-for-windows\usr\bin

 9:55:02.18 DEBUG(init.bat): START - bin(prepend): Env Var - PATH=C:\tools\cmder-1464\vendor\bin;C:\tools\cmder-1464\vendor\git-for-windows\cmd;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;;C:\tools\cmder-1464\vendor\git-for-windows\usr\bin

 9:55:02.21 DEBUG(init.bat): END - bin(prepend): Env Var - PATH=C:\tools\cmder-1464\bin;C:\tools\cmder-1464\vendor\bin;C:\tools\cmder-1464\vendor\git-for-windows\cmd;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;;C:\tools\cmder-1464\vendor\git-for-windows\usr\bin

 9:55:02.24 DEBUG(init.bat): START - cmder_root(append): Env Var - PATH=C:\tools\cmder-1464\bin;C:\tools\cmder-1464\vendor\bin;C:\tools\cmder-1464\vendor\git-for-windows\cmd;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;;C:\tools\cmder-1464\vendor\git-for-windows\usr\bin

 9:55:02.29 DEBUG(init.bat): END - cmder_root(append): Env Var - PATH=C:\tools\cmder-1464\bin;C:\tools\cmder-1464\vendor\bin;C:\tools\cmder-1464\vendor\git-for-windows\cmd;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;;C:\tools\cmder-1464\vendor\git-for-windows\usr\bin;C:\tools\cmder-1464

Creating initial user_aliases store in "C:\tools\cmder-1464\config\user_aliases.cmd"...
        1 file(s) copied.
Running Git for Windows one time Post Install....
"running post-install"
'C:\Windows\system32\drivers\etc\hosts' -> '/etc/hosts'
'C:\Windows\system32\drivers\etc\protocol' -> '/etc/protocols'
'C:\Windows\system32\drivers\etc\services' -> '/etc/services'
'C:\Windows\system32\drivers\etc\networks' -> '/etc/networks'
The batch file cannot be found.
 9:55:06.34 DEBUG(init.bat): Env Var - HOME=C:\Users\WDAGUtilityAccount

Creating user startup file: "C:\tools\cmder-1464\config\user_profile.cmd"
        1 file(s) copied.
File C:\tools\cmder-1464\vendor\bin\create-cmdercfg.ps1 cannot be loaded because running scripts is disabled on this system. For
more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
    + CategoryInfo          : SecurityError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnauthorizedAccess
ERROR: Failed to generate Cmder config
Elapsed Time: 0:0:8.91 (8.91s total)

C:\tools\cmder-1464
λ ver

Microsoft Windows [Version 10.0.19041.2486]

Second run

12:00:02.04 DEBUG(init.bat): Env Var - CMDER_ROOT=C:\tools\cmder-1464

12:00:02.07 DEBUG(init.bat): Env Var - debug_output=1

12:00:02.20 DEBUG(init.bat): Looking for Git install root...

12:00:02.27 DEBUG(:read_version): Env Var - git_executable=C:\tools\cmder-1464\vendor\git-for-windows\cmd\git.exe

12:00:02.42 DEBUG(:read_version): Env Var - GIT_VERSION_VENDORED=2.39.0.windows.2

12:00:02.48 DEBUG(:validate_version): ARGV[1]=VENDORED, ARGV[2]=2.39.0.windows.2

12:00:02.51 DEBUG(:parse_version): ARGV[1]=VENDORED, ARGV[2]=2.39.0.windows.2

12:00:02.56 DEBUG(:validate_version): Found Git Version for VENDORED: 2.39.0.windows.2

12:00:02.85 DEBUG(init.bat): Using vendored Git '2.39.0.windows.2'...

12:00:02.88 DEBUG(init.bat): Using Git from 'C:\tools\cmder-1464\vendor\git-for-windows...

12:00:02.92 DEBUG(init.bat): START - git.exe(prepend): Env Var - PATH=C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;

12:00:02.95 DEBUG(init.bat): END - git.exe(prepend): Env Var - PATH=C:\tools\cmder-1464\vendor\git-for-windows\cmd;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;

12:00:02.98 DEBUG(init.bat): START - nix_tools(append): Env Var - PATH=C:\tools\cmder-1464\vendor\git-for-windows\cmd;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;

12:00:03.01 DEBUG(init.bat): END - nix_tools(append): Env Var - PATH=C:\tools\cmder-1464\vendor\git-for-windows\cmd;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;;C:\tools\cmder-1464\vendor\git-for-windows\usr\bin

12:00:03.17 DEBUG(init.bat): Found Git in: 'GIT_INSTALL_ROOT=C:\tools\cmder-1464\vendor\git-for-windows'

12:00:03.20 DEBUG(init.bat): START - vendor/bin(prepend): Env Var - PATH=C:\tools\cmder-1464\vendor\git-for-windows\cmd;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;;C:\tools\cmder-1464\vendor\git-for-windows\usr\bin

12:00:03.23 DEBUG(init.bat): END - vendor/bin(prepend): Env Var - PATH=C:\tools\cmder-1464\vendor\bin;C:\tools\cmder-1464\vendor\git-for-windows\cmd;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;;C:\tools\cmder-1464\vendor\git-for-windows\usr\bin

12:00:03.26 DEBUG(init.bat): START - bin(prepend): Env Var - PATH=C:\tools\cmder-1464\vendor\bin;C:\tools\cmder-1464\vendor\git-for-windows\cmd;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;;C:\tools\cmder-1464\vendor\git-for-windows\usr\bin

12:00:03.31 DEBUG(init.bat): END - bin(prepend): Env Var - PATH=C:\tools\cmder-1464\bin;C:\tools\cmder-1464\vendor\bin;C:\tools\cmder-1464\vendor\git-for-windows\cmd;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;;C:\tools\cmder-1464\vendor\git-for-windows\usr\bin

12:00:03.34 DEBUG(init.bat): START - cmder_root(append): Env Var - PATH=C:\tools\cmder-1464\bin;C:\tools\cmder-1464\vendor\bin;C:\tools\cmder-1464\vendor\git-for-windows\cmd;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;;C:\tools\cmder-1464\vendor\git-for-windows\usr\bin

12:00:03.37 DEBUG(init.bat): END - cmder_root(append): Env Var - PATH=C:\tools\cmder-1464\bin;C:\tools\cmder-1464\vendor\bin;C:\tools\cmder-1464\vendor\git-for-windows\cmd;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu\Scripts;C:\tools\cmder-1464\vendor\conemu-maximus5;C:\tools\cmder-1464\vendor\conemu-maximus5\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;;C:\tools\cmder-1464\vendor\git-for-windows\usr\bin;C:\tools\cmder-1464

12:00:03.62 DEBUG(init.bat): Env Var - HOME=C:\Users\WDAGUtilityAccount

12:00:03.65 DEBUG(init.bat): Calling - C:\tools\cmder-1464\config\user_profile.cmd

File C:\tools\cmder-1464\vendor\bin\create-cmdercfg.ps1 cannot be loaded because running scripts is disabled on this system. For
more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
    + CategoryInfo          : SecurityError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnauthorizedAccess
ERROR: Failed to generate Cmder config
Elapsed Time: 0:0:5.42 (5.42s total)

Clink v1.4.19 is available.
- To apply the update, run 'clink update'.
- To stop checking for updates, run 'clink set clink.autoupdate false'.
- To view the release notes, visit the Releases page:
  https://github.com/chrisant996/clink/releases

@daxgames
Copy link
Member Author

daxgames commented Mar 5, 2023

@i-s-o Good catch. Try this

@i-s-o
Copy link

i-s-o commented Mar 6, 2023

@i-s-o Good catch. Try this

Yes, that fixes it.

@daxgames daxgames mentioned this pull request Apr 9, 2023
@DRSDavidSoft
Copy link
Contributor

@daxgames Thank you for the great PR, I'm in the process of reviewing it. Excited to merge it soon!

@daxgames
Copy link
Member Author

@DRSDavidSoft Hopefully it works as well for you as it has for me.

@DRSDavidSoft DRSDavidSoft changed the title optimize for speed Optimizations for improving speed Jul 24, 2023
@DRSDavidSoft
Copy link
Contributor

I'm merging this in the development branch for further review. Please use the development branch as a base for any future PRs, I'll review your great changes very soon. Thank you once again! 🤝

Comment on lines +130 to +131
<value name="ConWnd X" type="long" data="2194"/>
<value name="ConWnd Y" type="long" data="95"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the starting X,Y position be changed?

@daxgames
Copy link
Member Author

Why are we getting back to using a development branch we abandonded that practice years ago.

@DRSDavidSoft
Copy link
Contributor

@daxgames Good for the CI, because GitHub actions can produce compiled versions of branches. I just wanted to keep the master branch "stable" for now. When we merge development back into master eventually, they will contain the same commits. Sorry if it caused any issues

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

Successfully merging this pull request may close these issues.

4 participants