-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Namespace]: Reduce time taken during get_all from all namespaces #137
Conversation
interface index and database instance to avoid checking if a key exists every time for get_all. Signed-off-by: SuvarnaMeenakshi <[email protected]>
Signed-off-by: SuvarnaMeenakshi <[email protected]>
Signed-off-by: SuvarnaMeenakshi <[email protected]>
Signed-off-by: SuvarnaMeenakshi <[email protected]>
Signed-off-by: SuvarnaMeenakshi <[email protected]>
src/sonic_ax_impl/mibs/__init__.py
Outdated
|
||
""" | ||
all_ns_db - will have db_conn to all namespace DBs and | ||
global db. First db in the list is global db. | ||
Ignore first global db to get interface tables if there | ||
are multiple namespaces. | ||
""" | ||
for db_conn in Namespace.get_non_host_dbs(dbs): | ||
for inst in range(Namespace.get_start_idx_of_non_host(dbs), len(dbs)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inst [](start = 12, length = 4)
ns_index or ns ? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ns_index; basically, the index in db array.
index is not same as namespace, index 0 will be host namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated as per comment
self.if_range.append((if_oid, )) | ||
self.if_range.sort() | ||
if not self.loc_port_data: | ||
logger.warning("0 - b'PORT_TABLE' is empty. No local port information could be retrieved.") | ||
|
||
def _get_if_entry(self, if_name): | ||
def _get_if_entry(self, if_name, db_inst): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
db_inst [](start = 37, length = 7)
db_index? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated as per comment
if len(dbs) == 1: | ||
return 0 | ||
else: | ||
return 1 | ||
|
||
@staticmethod | ||
def init_namespace_sync_d_interface_tables(dbs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
init_namespace_sync_d [](start = 8, length = 21)
I see a common pattern in all the functions like init_namespace_sync_d*
. They just call the single db function and merge all returned items respectively.
How about abstract this high level function and return a dictionary of list, in this case the type is db -> { if_name_map, if_alias_map, if_id_map, oid_sai_map, oid_name_map, if_oid_namespace }
This comment is also true on dbs_keys_namespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the MIB implementations, we generally use a single dict to look up the if_index etc. If we have a dict of lists, then we will have to loop through this dict for each instance of the db and look for the if_index, which will make the code look bulky in the places where these functions are used.
src/sonic_ax_impl/mibs/__init__.py
Outdated
|
||
|
||
@staticmethod | ||
def get_start_idx_of_non_host(dbs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_start_idx_of_non_host [](start = 8, length = 25)
You can return a range since all use cases are in a range. You can further implement get_non_host_dbs by this function.
A better name will be get_non_host_db_indexes
#Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated as per comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As comments
Signed-off-by: SuvarnaMeenakshi <[email protected]>
Signed-off-by: SuvarnaMeenakshi <[email protected]>
Signed-off-by: SuvarnaMeenakshi <[email protected]>
Signed-off-by: SuvarnaMeenakshi <[email protected]>
This pull request introduces 1 alert when merging effc505 into 253f58e - view on LGTM.com new alerts:
|
Signed-off-by: SuvarnaMeenakshi <[email protected]>
@@ -233,9 +233,9 @@ def update_data(self): | |||
if not self.pubsub[i]: | |||
pattern = self.TRANSCEIVER_KEY_PATTERN | |||
self.pubsub[i] = mibs.get_redis_pubsub(self.statedb[i], self.statedb[i].STATE_DB, pattern) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to __init__()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is currently in sonic_ax_impl/mibs/init.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I mean the section is only needed once after each time db connected.
for i in range(len(self.statedb)):
if not self.pubsub[i]:
pattern = self.TRANSCEIVER_KEY_PATTERN
self.pubsub[i] = mibs.get_redis_pubsub(self.statedb[i], self.statedb[i].STATE_DB, pattern)
In reply to: 451174442 [](ancestors = 451174442)
|
||
def _update_per_namespace_data(self, pubsub): | ||
def _update_per_namespace_data(self, pubsub, db_instance): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
db_instance [](start = 49, length = 11)
db_index #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated as per comment.
Signed-off-by: SuvarnaMeenakshi <[email protected]>
Signed-off-by: SuvarnaMeenakshi <[email protected]>
This pull request introduces 1 alert when merging 61c0d91 into 253f58e - view on LGTM.com new alerts:
|
Signed-off-by: SuvarnaMeenakshi <[email protected]>
Will raise a new PR to fix the comment: Time reduction and socket connection error is fixed in PR #140 |
- What I did
To support namespaces, we added a Namespace class with functions to support getting data from all databases.
The Namespace dbs_get_all function , checks if the key exists in the database before executing get_all.
This additional check was causing additional time, which was causing agentx socket to disconnect.
- How I did it
- How to verify it
Make sure unit-test passes.
Make sure single-asic platform test cases are passing and no error message is observed in the syslog.
Check snmp output in multi-asic platform.
- Description for the changelog