Skip to content

Commit

Permalink
Remove jinja2_cache (#11996)
Browse files Browse the repository at this point in the history
- Why I did it
As part of Persistent log level HLD , LOGLEVEL_DB content is moved to CONFIG_DB.
In addition, it was decided to remove jinja2_cache which currently appear on LOGLEVEL_DB

This cache was added to speed up template rendering in start scripts. There were a lot of them rendered during system start. This caused a delay in warm boot LAG restore time. It was tested and verified that with and without the cache we don't see any difference in this timing now. It is probably due to a lot of other optimizations done to sonic-cfggen. Since there is no noticeable improvement made by j2 cache now it is safe to remove it.

- How I did it
Remove redis_bcc.py file and and remove the bytcode_cache from sonic-sfggen

- How to verify it
Warm boot was tested with \ without this jinja2_cache and it there is no difference in performance
  • Loading branch information
dprital authored Sep 20, 2022
1 parent e662008 commit f30fc76
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 34 deletions.
29 changes: 0 additions & 29 deletions src/sonic-config-engine/redis_bcc.py

This file was deleted.

1 change: 0 additions & 1 deletion src/sonic-config-engine/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
'minigraph',
'openconfig_acl',
'portconfig',
'redis_bcc',
]
if sys.version_info.major == 3:
# Python 3-only modules
Expand Down
6 changes: 2 additions & 4 deletions src/sonic-config-engine/sonic-cfggen
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ from config_samples import generate_sample_config, get_available_config
from functools import partial
from minigraph import minigraph_encoder, parse_xml, parse_device_desc_xml, parse_asic_sub_role, parse_asic_switch_type
from portconfig import get_port_config, get_breakout_mode
from redis_bcc import RedisBytecodeCache
from sonic_py_common.multi_asic import get_asic_id_from_name, get_asic_device_id, is_multi_asic
from sonic_py_common import device_info
from swsscommon.swsscommon import SonicV2Connector, ConfigDBConnector, SonicDBConfig, ConfigDBPipeConnector
from swsscommon.swsscommon import ConfigDBConnector, SonicDBConfig, ConfigDBPipeConnector


PY3x = sys.version_info >= (3, 0)
Expand Down Expand Up @@ -241,8 +240,7 @@ def _get_jinja2_env(paths):
Retreive Jinj2 env used to render configuration templates
"""
loader = jinja2.FileSystemLoader(paths)
redis_bcc = RedisBytecodeCache(SonicV2Connector(host='127.0.0.1'))
env = jinja2.Environment(loader=loader, trim_blocks=True, bytecode_cache=redis_bcc)
env = jinja2.Environment(loader=loader, trim_blocks=True)
env.filters['sort_by_port_index'] = sort_by_port_index
env.filters['ipv4'] = is_ipv4
env.filters['ipv6'] = is_ipv6
Expand Down

0 comments on commit f30fc76

Please sign in to comment.