-
Notifications
You must be signed in to change notification settings - Fork 27
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
Split APIHelper out into its own file #137
Conversation
This allow to only import it when needed, speeding up the CLI for easy tasks, especially the auto-completion provided by click [1]. This is most noticable when site packages are enabled (as with the command "python -m virtualenv --system-site-packages") or on global installations, like with the official Debian package. Before $time synadm > /dev/null real 0m0,610s user 0m0,537s sys 0m0,072s After $time synadm > /dev/null real 0m0,086s user 0m0,077s sys 0m0,009s [1]: https://click.palletsprojects.com/en/latest/shell-completion/
4f770c1
to
42d70b6
Compare
Some actual benchmarking:
|
This really looks like filesystem caching in action, so this benchmark likely isn't good. |
Thank you, I wasn't motivated enough to do it!
Not really, I didn't take the first run, subsequent runs are all about the same time. Details
$ for i in $(seq 10); do time synadm > /dev/null; done
real 0m0,619s
user 0m0,539s
sys 0m0,080s
real 0m0,600s
user 0m0,508s
sys 0m0,092s
real 0m0,612s
user 0m0,544s
sys 0m0,068s
real 0m0,597s
user 0m0,537s
sys 0m0,060s
real 0m0,643s
user 0m0,568s
sys 0m0,076s
real 0m0,606s
user 0m0,523s
sys 0m0,084s
real 0m0,601s
user 0m0,532s
sys 0m0,068s
real 0m0,609s
user 0m0,529s
sys 0m0,080s
real 0m0,601s
user 0m0,569s
sys 0m0,032s
real 0m0,595s
user 0m0,495s
sys 0m0,100s Also note that it really depends on the quantity of python libraries installed on the system. For instance in a bare-bones virtualenv the difference it is almost not noticeable. |
Hmm, I'll try barebones venv in both cases later. |
Sorry I meant the difference is almost not noticeable. Meaning it is almost the same time for both my changes and master. |
Some more numbers to explain the differences: $ # master in venv made with `python -m virtualenv --system-site-packages`
$ strace synadm 2>&1 | wc -l
13251
$ # this branche in venv made with `python -m virtualenv --system-site-packages`
$ strace synadm 2>&1 | wc -l
1668
$ # master in normal venv
$ strace synadm 2>&1 | wc -l
4448
$ # this branch in normal venv
$ strace synadm 2>&1 | wc -l
1537 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi to both of you,
awesome idea. Splitting out into a separate file is a good idea even if it was not for performance. I didn't realize that there is a Debian package and you are the maintainer @n-peugnet, that is great news as well! Thanks so much for taking care of that. Tab completion for synadm also sounds like a very handy feature for the package. We certainly should work towards making that a pleasent user experience.
One change request: Please let's name that file _helper.py
.
I am not the official maintainer but I intend to send him a patch to add the completion script in the package.
This is exactly when testing this completion script (generated by click) that loads the python project each time that I noticed the startup was quite slow.
I can do that in a few days. Not that much time right now. |
would it be fine if i did it? |
Yes of course! |
hmmm, do you have maintainer edits enabled? doesn't seem like it to me. if you do have time, you can do it yourself instead. |
Sorry, I thought I did.
Just did it now. |
Hi, sorry for the delay @n-peugnet . I just wanted to quickly add some refinements to the docstrings of the modules. Are you sure you have maintainer edits enabled? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, added module-level docstring refinements as code suggestions.
Co-authored-by: J0J0 Todos <[email protected]>
After moving APIHelper to its own file _helper.py in #137, the class was not found by Sphinx autodoc anymore, thus missing in the docs and we didn't catch the warning at build time.
After moving APIHelper to its own file _helper.py in #137, the class was not found by Sphinx autodoc anymore, thus missing in the docs and we didn't catch the warning at build time.
This allow to only import it when needed, speeding up the CLI for easy tasks, especially the auto-completion provided by click (that I intend to add to the Debian package). This is most noticable when site packages are enabled (as with the command
python -m virtualenv --system-site-packages
) or on global installations, like with the official Debian package.Before
After
References