[action] [PR:3513] Upgrade pyroute2 and improve cli response time (#3513) #3640
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What I did
root@msn2700:/home/admin# time python3 -c "import pyroute2" real 0m0.707s user 0m0.425s sys 0m0.097s 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.109sOlder 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.
root@msn2700:/home/admin# time python3 -c "import pyroute2"
real 0m0.378s
user 0m0.308s
sys 0m0.060s
root@msn2700/home/admin# time python3 -c "import utilities_common.cli as clicommon"
real 0m0.363s
user 0m0.271s
sys 0m0.072s