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 CLI startup time #194

Merged
merged 2 commits into from
Dec 5, 2022
Merged

Improve CLI startup time #194

merged 2 commits into from
Dec 5, 2022

Conversation

gryzus24
Copy link
Contributor

@gryzus24 gryzus24 commented Dec 5, 2022

Program startup time was really slow. After inspecting it with -Ximporttime it turned out to be pulling in a lot of unnecessary packages from pkg_resources responsible only for debug functionality.

Solution: reduce the scope of the debug import.

Note that this type of optimization is more of a hack than a solution, but considering it significantly improves startup time for the 99%+ of use cases it is worth implementing.

Before the patch:

$ time python3.10 -m rivalcfg --help > /dev/null

real	0m0,156s
user	0m0,125s
sys	0m0,023s

$ time python3.10 -m rivalcfg -s 800

real	0m0,260s
user	0m0,129s
sys	0m0,021s

After the patch:

$ time python3.10 -m rivalcfg --help > /dev/null

real	0m0,069s
user	0m0,050s
sys	0m0,011s

$ time python3.10 -m rivalcfg -s 800

real	0m0,185s
user	0m0,060s
sys	0m0,015s

@flozz
Copy link
Owner

flozz commented Dec 5, 2022

Hello,

Thank you for the PR! Please fix the codding style (missing blank line after import) to allow me to merge :)

@flozz flozz merged commit 517e501 into flozz:master Dec 5, 2022
@flozz
Copy link
Owner

flozz commented Dec 5, 2022

Thank you, this will be released with the next version :)

@gryzus24 gryzus24 deleted the importtime branch December 6, 2022 17:50
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.

None yet

2 participants