[sonic-cfggen] remove lazy_re workaround due to many optimizations done (#8226)
lazy_re had an issue when importing sonic-cfggen in another application that uses re.search(). There is no much improvement of lazy_re today after many other good optimization work done for sonic-cfggen. It served as a quick temporary solution. Some quick test for fast-reboot and warm-reboot done on top of 201911 branch: Fast-reboot: from ASIC reset to ports in up state: with lazy_re: 18 sec without lazy_re: 18 sec Warm-reboot: LAG restoration time: with lazy_re: 73 sec without lazy_re: 72 sec So, there is no real optimization since the number of sonic-cfggen calls is greatly reduced in latest SONiC. This means it is time to revert this change. Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
This commit is contained in:
parent
c5c53acf98
commit
73473dc4c4
@ -1,22 +0,0 @@
|
||||
# monkey patch re.compile to improve import time of some packages
|
||||
|
||||
import re
|
||||
|
||||
_orig_re_compile = re.compile
|
||||
|
||||
|
||||
def __re_compile(*args, **kwargs):
|
||||
class __LazyReCompile(object):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
self.pattern_obj = None
|
||||
|
||||
def __getattr__(self, name):
|
||||
if self.pattern_obj is None:
|
||||
self.pattern_obj = _orig_re_compile(*self.args, **self.kwargs)
|
||||
return getattr(self.pattern_obj, name)
|
||||
return __LazyReCompile(*args, **kwargs)
|
||||
|
||||
re.compile = __re_compile
|
||||
|
@ -40,7 +40,6 @@ else:
|
||||
# Common modules for python2 and python3
|
||||
py_modules = [
|
||||
'config_samples',
|
||||
'lazy_re',
|
||||
'minigraph',
|
||||
'openconfig_acl',
|
||||
'portconfig',
|
||||
|
@ -17,15 +17,6 @@ See usage string for detail description for arguments.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
# monkey patch re.compile to do lazy regular expression compilation.
|
||||
# This is done to improve import time of jinja2, yaml, natsort modules, because they
|
||||
# do many regexp compilation at import time, so it will speed up sonic-cfggen invocations
|
||||
# that do not require template generation or yaml loading. sonic-cfggen is used in so many places
|
||||
# during system boot up that importing jinja2, yaml, natsort every time
|
||||
# without lazy regular expression compilation affect boot up time.
|
||||
# FIXME: remove this once sonic-cfggen and templates dependencies are replaced with a faster approach
|
||||
import lazy_re
|
||||
|
||||
import argparse
|
||||
import contextlib
|
||||
import jinja2
|
||||
|
Loading…
Reference in New Issue
Block a user