diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-08-29 09:29:51 +0000 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2026-08-30 13:40:44 +0200 |
| commit | 662ad8e5a93298f8d4fe813bd615cf00d74cf4c4 (patch) | |
| tree | c52eb1442a76940d530458b4aacd02a73fd1f007 /scripts/cli | |
| parent | de81311ce99e1ce8776ac809c336726ad68d6751 (diff) | |
| download | vyos-1x-662ad8e5a93298f8d4fe813bd615cf00d74cf4c4.tar.gz vyos-1x-662ad8e5a93298f8d4fe813bd615cf00d74cf4c4.zip | |
vyos: T9261: defer more heavy imports off the CLI hot paths
Follow-up sweep to f696b2d65. Every conf-mode script not handled in-daemon by
vyos-configd, every op-mode script and every Python validator is a fresh
interpreter, so module-scope imports of heavy dependencies are paid over and
over - which is what makes the CLI feel sluggish on CPUs with little cache.
configsource.py imported vyos.vyconf_session, and with it google.protobuf, for
a class that is only instantiated when the vyconf backend is active. opmode.py
imported ConfigTreeQuery for a single decorator most op-mode scripts never use.
template.py imported jinja2 at module scope although Environment is only touched
in the lru_cache'd _get_environment(), while most callers want just the
is_ipv4/is_ipv6 predicates. ethtool.py pulled pyroute2 via vyos.netlink for two
calls in Ethtool.__init__. ifconfig/interface.py pulled the whole cryptography
stack via vyos.pki for set_eapol() alone. Also deferred: netaddr, jmespath,
tabulate, hurry.filesize, vyos.ifconfig in qos, and cracklib - the last of which
also opens its dictionary database on import.
import vyos.opmode 34.0 -> 4.6 ms (-86%), 206 -> 71 modules
import vyos.ifconfig 132.9 -> 30.8 ms (-77%), 618 -> 193 modules
import vyos.config 40.7 -> 20.6 ms (-49%), 194 -> 130 modules
import vyos.qos 134.1 -> 12.5 ms (-91%), 631 -> 124 modules
import vyos.template 18.8 -> 6.3 ms (-66%), 153 -> 89 modules
import vyos.firewall 22.2 -> 12.2 ms (-45%), 168 -> 114 modules
Deferring textwrap in base.py and logging in configtree.py was measured too and
made no difference; both were left alone.
Diffstat (limited to 'scripts/cli')
0 files changed, 0 insertions, 0 deletions
