Skip to content

Commit 103fdf0

Browse files
authored
Remove redundant calls to get child scheduler group during initialization (#1965)
- What I did The QoS orchagent calls SAI APIs to get the number of child scheduler groups and then initialize them. After that, the size of the child scheduler groups vector will be non-zero, which indicates the child scheduler groups have been initialized and prevents QoS orchagent from calling SAI get APIs again. However, on some platforms, it may be that some of the scheduler groups don't have child groups, leaving size of child scheduler groups always being zero. It causes QoS orchagent to call the SAI get API each time the scheduler group is handled, which wastes a lot of time, especially during fast reboot. An extra flag indicating whether the child groups have been initialized is introduced to avoid redundant calls. - Why I did it To optimize QoS orchagent performance during initialization especially for fast reboot. - How I verified it It can be covered by the existing regression test. - Details if related I did a pair of tests, comparing the time to handle scheduler and child scheduler groups between the old and the new (optimized) version. Dump and sairedis.record attached. Signed-off-by: Stephen Sun <[email protected]>
1 parent 18ea840 commit 103fdf0

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

orchagent/qosorch.cpp

+20-6
Original file line numberDiff line numberDiff line change
@@ -1225,18 +1225,29 @@ sai_object_id_t QosOrch::getSchedulerGroup(const Port &port, const sai_object_id
12251225

12261226
m_scheduler_group_port_info[port.m_port_id] = {
12271227
.groups = std::move(groups),
1228-
.child_groups = std::vector<std::vector<sai_object_id_t>>(groups_count)
1228+
.child_groups = std::vector<std::vector<sai_object_id_t>>(groups_count),
1229+
.group_has_been_initialized = std::vector<bool>(groups_count)
12291230
};
1230-
}
1231+
1232+
SWSS_LOG_INFO("Port %s has been initialized with %u group(s)", port.m_alias.c_str(), groups_count);
1233+
}
12311234

12321235
/* Lookup groups to which queue belongs */
1233-
const auto& groups = m_scheduler_group_port_info[port.m_port_id].groups;
1236+
auto& scheduler_group_port_info = m_scheduler_group_port_info[port.m_port_id];
1237+
const auto& groups = scheduler_group_port_info.groups;
12341238
for (uint32_t ii = 0; ii < groups.size() ; ii++)
12351239
{
12361240
const auto& group_id = groups[ii];
1237-
const auto& child_groups_per_group = m_scheduler_group_port_info[port.m_port_id].child_groups[ii];
1241+
const auto& child_groups_per_group = scheduler_group_port_info.child_groups[ii];
12381242
if (child_groups_per_group.empty())
12391243
{
1244+
if (scheduler_group_port_info.group_has_been_initialized[ii])
1245+
{
1246+
// skip this iteration if it has been initialized which means there're no children in this group
1247+
SWSS_LOG_INFO("No child group for port %s group 0x%" PRIx64 ", skip", port.m_alias.c_str(), group_id);
1248+
continue;
1249+
}
1250+
12401251
attr.id = SAI_SCHEDULER_GROUP_ATTR_CHILD_COUNT;//Number of queues/groups childs added to scheduler group
12411252
sai_status = sai_scheduler_group_api->get_scheduler_group_attribute(group_id, 1, &attr);
12421253
if (SAI_STATUS_SUCCESS != sai_status)
@@ -1250,14 +1261,17 @@ sai_object_id_t QosOrch::getSchedulerGroup(const Port &port, const sai_object_id
12501261
}
12511262

12521263
uint32_t child_count = attr.value.u32;
1253-
vector<sai_object_id_t> child_groups(child_count);
1264+
1265+
SWSS_LOG_INFO("Port %s group 0x%" PRIx64 " has been initialized with %u child group(s)", port.m_alias.c_str(), group_id, child_count);
1266+
scheduler_group_port_info.group_has_been_initialized[ii] = true;
12541267

12551268
// skip this iteration if there're no children in this group
12561269
if (child_count == 0)
12571270
{
12581271
continue;
12591272
}
12601273

1274+
vector<sai_object_id_t> child_groups(child_count);
12611275
attr.id = SAI_SCHEDULER_GROUP_ATTR_CHILD_LIST;
12621276
attr.value.objlist.list = child_groups.data();
12631277
attr.value.objlist.count = child_count;
@@ -1272,7 +1286,7 @@ sai_object_id_t QosOrch::getSchedulerGroup(const Port &port, const sai_object_id
12721286
}
12731287
}
12741288

1275-
m_scheduler_group_port_info[port.m_port_id].child_groups[ii] = std::move(child_groups);
1289+
scheduler_group_port_info.child_groups[ii] = std::move(child_groups);
12761290
}
12771291

12781292
for (const auto& child_group_id: child_groups_per_group)

orchagent/qosorch.h

+1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ class QosOrch : public Orch
189189
{
190190
std::vector<sai_object_id_t> groups;
191191
std::vector<std::vector<sai_object_id_t>> child_groups;
192+
std::vector<bool> group_has_been_initialized;
192193
};
193194

194195
std::unordered_map<sai_object_id_t, SchedulerGroupPortInfo_t> m_scheduler_group_port_info;

0 commit comments

Comments
 (0)