Commit 695cc9a
authored
Upgrade pyroute2 and improve cli response time (sonic-net#3513)
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.072s1 parent 867fc54 commit 695cc9a
2 files changed
+3
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | | - | |
| 251 | + | |
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
| |||
170 | 169 | | |
171 | 170 | | |
172 | 171 | | |
| 172 | + | |
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| 184 | + | |
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
| |||
0 commit comments