Skip to content

Commit dd9a8ea

Browse files
zhenggen-xuqiluo-msft
authored andcommitted
Fix snmp mac polling performance issue. (sonic-net#95)
When SONiC system get a few hundreds MACs learnt on vlans, snmp-subagent started to see below errors: INFO supervisord: snmp-subagent socket.send() raised exception. ERR snmp-subagent [ax_interface] ERROR: [Errno 32] Broken pipe This was due to the snmpd getting timeout from subagent and closed the socket. It was root caused to be the mac polling algorithm inefficiency. The redis-server was taking average > 60% CPU cycles (peak to 85~90%) of one core. After the fix in this commit, the redis-server load is average to ~3% (peak to ~6%) of one core.
1 parent 660a752 commit dd9a8ea

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/sonic_ax_impl/mibs/ietf/rfc4363.py

+15-10
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
from ax_interface.util import mac_decimals
88
from bisect import bisect_right
99

10-
def fdb_vlanmac(db_conn, fdb):
11-
if 'vlan' in fdb:
12-
vlan_id = fdb["vlan"]
13-
elif 'bvid' in fdb:
14-
vlan_id = port_util.get_vlan_id_from_bvid(db_conn, fdb["bvid"])
15-
return (int(vlan_id),) + mac_decimals(fdb["mac"])
16-
1710
class FdbUpdater(MIBUpdater):
1811
def __init__(self):
1912
super().__init__()
@@ -27,7 +20,19 @@ def __init__(self):
2720
self.vlanmac_ifindex_map = {}
2821
self.vlanmac_ifindex_list = []
2922
self.if_bpid_map = {}
30-
23+
self.bvid_vlan_map = {}
24+
25+
def fdb_vlanmac(self, fdb):
26+
if 'vlan' in fdb:
27+
vlan_id = fdb["vlan"]
28+
elif 'bvid' in fdb:
29+
if fdb["bvid"] in self.bvid_vlan_map:
30+
vlan_id = self.bvid_vlan_map[fdb["bvid"]]
31+
else:
32+
vlan_id = port_util.get_vlan_id_from_bvid(self.db_conn, fdb["bvid"])
33+
self.bvid_vlan_map[fdb["bvid"]] = vlan_id
34+
return (int(vlan_id),) + mac_decimals(fdb["mac"])
35+
3136
def reinit_data(self):
3237
"""
3338
Subclass update interface information
@@ -39,7 +44,7 @@ def reinit_data(self):
3944
self.oid_name_map = mibs.init_sync_d_interface_tables(self.db_conn)
4045

4146
self.if_bpid_map = port_util.get_bridge_port_map(self.db_conn)
42-
47+
self.bvid_vlan_map.clear()
4348

4449
def update_data(self):
4550
"""
@@ -69,7 +74,7 @@ def update_data(self):
6974
continue
7075
port_id = self.if_bpid_map[bridge_port_id]
7176

72-
vlanmac = fdb_vlanmac(self.db_conn, fdb)
77+
vlanmac = self.fdb_vlanmac(fdb)
7378
self.vlanmac_ifindex_map[vlanmac] = mibs.get_index(self.if_id_map[port_id])
7479
self.vlanmac_ifindex_list.append(vlanmac)
7580
self.vlanmac_ifindex_list.sort()

0 commit comments

Comments
 (0)