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

Improve init speed #2430

Merged
merged 2 commits into from
Dec 11, 2020
Merged

Improve init speed #2430

merged 2 commits into from
Dec 11, 2020

Conversation

kaimac1
Copy link
Contributor

@kaimac1 kaimac1 commented Dec 7, 2020

Hello,

The init scripts (init.bat and the files in vendor/lib) are full of calls to lib_console for debug/verbose logging. Unfortunately these calls have a cost which adds up to quite a lot. The reason is that doing e.g. %lib_console% debug_output .... invokes call, which is relatively slow. This cost is paid even if debug/verbose logging is turned off, which of course it is most of the time.

I have replaced such lines with %print_debug%/%print_verbose% instead, which first check that the relevant flag is set. I have added %print_error% for consistency, though this doesn't give any performance improvement. The original way to print, %lib_console% debug_output ... still works in case it's used somewhere else.

On my machine, without this change, the latest version of cmder_mini takes 1.41 sec on average to init (measured with time_init flag). With the change it takes 1.02 sec, so almost a 30% improvement.

@daxgames
Copy link
Member

daxgames commented Dec 8, 2020

I will take a look. I already have a branch I am working on the gets rid of everything in %cmder_root%\vendor\lib

@daxgames
Copy link
Member

I tested the PR and it did not work as expected. I sped things up but I got:

image

Also enabling debug does not show any debug messages correctly.

image

vs.

image

@kaimac1
Copy link
Contributor Author

kaimac1 commented Dec 10, 2020

Oops, that last commit should fix things. The "if" errors were coming from the delayed expansion "!print_debug!" calls. I've replaced them with %print_debug% as I can't see why the expansion would change - hopefully you can confirm that's ok.

@daxgames
Copy link
Member

Results of further testing:

Yours : Master : Mine

image

@daxgames daxgames merged commit 9088a5e into cmderdev:master Dec 11, 2020
@daxgames
Copy link
Member

Thanks for the PR - Merged

@kaimac1
Copy link
Contributor Author

kaimac1 commented Dec 11, 2020

Thanks for maintaining cmder! I look forward to your even faster version.

@DRSDavidSoft
Copy link
Contributor

Unfortunately, this is having a side effect:

If the %debug_output%/%verbose_output% variables are not set before init.bat is ran, if %debug_output% gtr 0 is always hardcoded to if 0 gtr 0 before those variables are set in the :var_loop loop.

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

Successfully merging this pull request may close these issues.

3 participants