-
Notifications
You must be signed in to change notification settings - Fork 722
Upgrade pyroute2 and improve cli response time #3513
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
50e311a
to
d48074b
Compare
@qiluo-msft Requesting waiver to ignore the coverage failure. I tried adding an UT to cover the multi_asic_get_ip_intf_from_ns and multi_asic_get_ip_intf_addr_from_ns methods (50e311a) .
This is because the monkey patched API is called instead of the actual API
Thus i couldn't add a UT to cover the lines i've added. This PR just changes the location of import and so no major functionality change that warrants a UT |
Thanks for the UT effort! Could you further explore if you can just disable multi_asic_get_ip_intf_from_ns monkey patch in your specific testcase? We should not globally enable one function monkey patch, because it will prevent us to UT the the function itself. In reply to: 2330382035 |
Hi, i checked but monkey patching is global. once the file is imported and loaded, the original api is lost. I suppose this can be updated but changing this would also probably require some other Multi Asic UT's to also be updated and so i think this should be taken as a separate item |
@vivekrnv Can you raise a PR to do the cherry-pick to 202405 since automation is not working? |
What I did Older pyroute2 depends on distutils. Thus upgrade the version to latest to improve import time. A similar issue for natsort is reported here [warm-reboot] natsort import is taking more time with python 3.11 in bookworm sonic-buildimage#17246. However pyroute2 import is still heavy in bookworm and thus every CLI command is slow compared to bullseye. <Bullseye> root@msn2700:/home/admin# time python3 -c "import pyroute2" real 0m0.378s user 0m0.308s sys 0m0.060s <Before upgrade> root@msn2700:/home/admin# time python3 -c "import pyroute2" real 0m0.707s user 0m0.425s sys 0m0.097s <After upgrade> root@msn2700:/home/admin# time python3 -c "import pyroute2" real 0m0.511s user 0m0.433s sys 0m0.075s To fix this, i've delayed the pyroute2 import into the method where it is actually used, this has an improvement of 0.4 sec for all the CLI commands on slower CPU devices root@msn2700:/home/admin# time python3 -c "import utilities_common.cli as clicommon" real 0m0.693s user 0m0.579s sys 0m0.109s root@msn2700/home/admin# time python3 -c "import utilities_common.cli as clicommon" real 0m0.363s user 0m0.271s sys 0m0.072s
Cherry-pick PR to 202405: #3640 |
What I did Older pyroute2 depends on distutils. Thus upgrade the version to latest to improve import time. A similar issue for natsort is reported here [warm-reboot] natsort import is taking more time with python 3.11 in bookworm sonic-buildimage#17246. However pyroute2 import is still heavy in bookworm and thus every CLI command is slow compared to bullseye. <Bullseye> root@msn2700:/home/admin# time python3 -c "import pyroute2" real 0m0.378s user 0m0.308s sys 0m0.060s <Before upgrade> root@msn2700:/home/admin# time python3 -c "import pyroute2" real 0m0.707s user 0m0.425s sys 0m0.097s <After upgrade> root@msn2700:/home/admin# time python3 -c "import pyroute2" real 0m0.511s user 0m0.433s sys 0m0.075s To fix this, i've delayed the pyroute2 import into the method where it is actually used, this has an improvement of 0.4 sec for all the CLI commands on slower CPU devices root@msn2700:/home/admin# time python3 -c "import utilities_common.cli as clicommon" real 0m0.693s user 0m0.579s sys 0m0.109s root@msn2700/home/admin# time python3 -c "import utilities_common.cli as clicommon" real 0m0.363s user 0m0.271s sys 0m0.072s
What I did Older pyroute2 depends on distutils. Thus upgrade the version to latest to improve import time. A similar issue for natsort is reported here [warm-reboot] natsort import is taking more time with python 3.11 in bookworm sonic-buildimage#17246. However pyroute2 import is still heavy in bookworm and thus every CLI command is slow compared to bullseye. <Bullseye> root@msn2700:/home/admin# time python3 -c "import pyroute2" real 0m0.378s user 0m0.308s sys 0m0.060s <Before upgrade> root@msn2700:/home/admin# time python3 -c "import pyroute2" real 0m0.707s user 0m0.425s sys 0m0.097s <After upgrade> root@msn2700:/home/admin# time python3 -c "import pyroute2" real 0m0.511s user 0m0.433s sys 0m0.075s To fix this, i've delayed the pyroute2 import into the method where it is actually used, this has an improvement of 0.4 sec for all the CLI commands on slower CPU devices root@msn2700:/home/admin# time python3 -c "import utilities_common.cli as clicommon" real 0m0.693s user 0m0.579s sys 0m0.109s root@msn2700/home/admin# time python3 -c "import utilities_common.cli as clicommon" real 0m0.363s user 0m0.271s sys 0m0.072s
What I did
How I did it
How to verify it
Previous command output (if the output of a command-line utility has changed)
New command output (if the output of a command-line utility has changed)