Skip to content

Commit 9336438

Browse files
Revert "Optimize counter polling interval by making it more accurate (#3391)"
This reverts commit 60433c7.
1 parent 762abd7 commit 9336438

File tree

6 files changed

+4
-138
lines changed

6 files changed

+4
-138
lines changed

orchagent/flexcounterorch.cpp

-24
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,6 @@ void FlexCounterOrch::doTask(Consumer &consumer)
138138

139139
if (op == SET_COMMAND)
140140
{
141-
string bulk_chunk_size;
142-
string bulk_chunk_size_per_counter;
143-
144141
for (auto valuePair:data)
145142
{
146143
const auto &field = fvField(valuePair);
@@ -158,14 +155,6 @@ void FlexCounterOrch::doTask(Consumer &consumer)
158155
}
159156
}
160157
}
161-
else if (field == BULK_CHUNK_SIZE_FIELD)
162-
{
163-
bulk_chunk_size = value;
164-
}
165-
else if (field == BULK_CHUNK_SIZE_PER_PREFIX_FIELD)
166-
{
167-
bulk_chunk_size_per_counter = value;
168-
}
169158
else if(field == FLEX_COUNTER_STATUS_FIELD)
170159
{
171160
// Currently, the counters are disabled for polling by default
@@ -287,19 +276,6 @@ void FlexCounterOrch::doTask(Consumer &consumer)
287276
SWSS_LOG_NOTICE("Unsupported field %s", field.c_str());
288277
}
289278
}
290-
291-
if (!bulk_chunk_size.empty() || !bulk_chunk_size_per_counter.empty())
292-
{
293-
m_groupsWithBulkChunkSize.insert(key);
294-
setFlexCounterGroupBulkChunkSize(flexCounterGroupMap[key],
295-
bulk_chunk_size.empty() ? "NULL" : bulk_chunk_size,
296-
bulk_chunk_size_per_counter.empty() ? "NULL" : bulk_chunk_size_per_counter);
297-
}
298-
else if (m_groupsWithBulkChunkSize.find(key) != m_groupsWithBulkChunkSize.end())
299-
{
300-
setFlexCounterGroupBulkChunkSize(flexCounterGroupMap[key], "NULL", "NULL");
301-
m_groupsWithBulkChunkSize.erase(key);
302-
}
303279
}
304280

305281
consumer.m_toSync.erase(it++);

orchagent/flexcounterorch.h

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ class FlexCounterOrch: public Orch
7575
Table m_deviceMetadataConfigTable;
7676
std::unique_ptr<SelectableTimer> m_delayTimer;
7777
std::unique_ptr<Executor> m_delayExecutor;
78-
std::unordered_set<std::string> m_groupsWithBulkChunkSize;
7978
};
8079

8180
#endif

orchagent/pfc_detect_mellanox.lua

100755100644
+4-40
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,13 @@ local timestamp_struct = redis.call('TIME')
1818
local timestamp_current = timestamp_struct[1] + timestamp_struct[2] / 1000000
1919
local timestamp_string = tostring(timestamp_current)
2020
redis.call('HSET', 'TIMESTAMP', 'pfcwd_poll_timestamp_last', timestamp_string)
21-
local global_effective_poll_time = poll_time
22-
local global_effective_poll_time_lasttime = redis.call('HGET', 'TIMESTAMP', 'effective_pfcwd_poll_time_last')
21+
local effective_poll_time = poll_time
22+
local effective_poll_time_lasttime = redis.call('HGET', 'TIMESTAMP', 'effective_pfcwd_poll_time_last')
2323
if timestamp_last ~= false then
24-
global_effective_poll_time = (timestamp_current - tonumber(timestamp_last)) * 1000000
25-
redis.call('HSET', 'TIMESTAMP', 'effective_pfcwd_poll_time_last', global_effective_poll_time)
24+
effective_poll_time = (timestamp_current - tonumber(timestamp_last)) * 1000000
25+
redis.call('HSET', 'TIMESTAMP', 'effective_pfcwd_poll_time_last', effective_poll_time)
2626
end
2727

28-
local effective_poll_time
29-
local effective_poll_time_lasttime
30-
local port_timestamp_last_cache = {}
31-
32-
local debug_storm_global = redis.call('HGET', 'DEBUG_STORM', 'enabled') == 'true'
33-
local debug_storm_threshold = tonumber(redis.call('HGET', 'DEBUG_STORM', 'threshold'))
34-
3528
-- Iterate through each queue
3629
local n = table.getn(KEYS)
3730
for i = n, 1, -1 do
@@ -63,37 +56,12 @@ for i = n, 1, -1 do
6356
local pfc_rx_pkt_key = 'SAI_PORT_STAT_PFC_' .. queue_index .. '_RX_PKTS'
6457
local pfc_duration_key = 'SAI_PORT_STAT_PFC_' .. queue_index .. '_RX_PAUSE_DURATION_US'
6558

66-
-- Get port specific timestamp
67-
local port_timestamp_current = tonumber(redis.call('HGET', counters_table_name .. ':' .. port_id, 'PFC_WD_time_stamp'))
68-
if port_timestamp_current ~= nil then
69-
local port_timestamp_lasttime = port_timestamp_last_cache[port_id]
70-
if port_timestamp_lasttime == nil then
71-
port_timestamp_lasttime = tonumber(redis.call('HGET', counters_table_name .. ':' .. port_id, 'PFC_WD_time_stamp_last'))
72-
port_timestamp_last_cache[port_id] = port_timestamp_lasttime
73-
redis.call('HSET', counters_table_name .. ':' .. port_id, 'PFC_WD_time_stamp_last', port_timestamp_current)
74-
end
75-
76-
if port_timestamp_lasttime ~= nil then
77-
effective_poll_time = (port_timestamp_current - port_timestamp_lasttime) / 1000
78-
else
79-
effective_poll_time = global_effective_poll_time
80-
end
81-
effective_poll_time_lasttime = false
82-
else
83-
effective_poll_time = global_effective_poll_time
84-
effective_poll_time_lasttime = global_effective_poll_time_lasttime
85-
end
86-
8759
-- Get all counters
8860
local occupancy_bytes = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES')
8961
local packets = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_QUEUE_STAT_PACKETS')
9062
local pfc_rx_packets = redis.call('HGET', counters_table_name .. ':' .. port_id, pfc_rx_pkt_key)
9163
local pfc_duration = redis.call('HGET', counters_table_name .. ':' .. port_id, pfc_duration_key)
9264

93-
if debug_storm_global then
94-
redis.call('PUBLISH', 'PFC_WD_DEBUG', 'Port ID ' .. port_id .. ' Queue index ' .. queue_index .. ' occupancy ' .. occupancy_bytes .. ' packets ' .. packets .. ' pfc rx ' .. pfc_rx_packets .. ' pfc duration ' .. pfc_duration .. ' effective poll time ' .. tostring(effective_poll_time) .. '(global ' .. tostring(global_effective_poll_time) .. ')')
95-
end
96-
9765
if occupancy_bytes and packets and pfc_rx_packets and pfc_duration then
9866
occupancy_bytes = tonumber(occupancy_bytes)
9967
packets = tonumber(packets)
@@ -114,10 +82,6 @@ for i = n, 1, -1 do
11482
pfc_duration_last = tonumber(pfc_duration_last)
11583
local storm_condition = (pfc_duration - pfc_duration_last) > (effective_poll_time * 0.99)
11684

117-
if debug_storm_threshold ~= nil and (pfc_duration - pfc_duration_last) > (effective_poll_time * debug_storm_threshold / 100) then
118-
redis.call('PUBLISH', 'PFC_WD_DEBUG', 'Port ID ' .. port_id .. ' Queue index ' .. queue_index .. ' occupancy ' .. occupancy_bytes .. ' packets ' .. packets .. ' pfc rx ' .. pfc_rx_packets .. ' pfc duration ' .. pfc_duration .. ' effective poll time ' .. tostring(effective_poll_time) .. ', triggered by threshold ' .. debug_storm_threshold .. '%')
119-
end
120-
12185
-- Check actual condition of queue being in PFC storm
12286
if (occupancy_bytes > 0 and packets - packets_last == 0 and storm_condition) or
12387
-- DEBUG CODE START. Uncomment to enable

orchagent/saihelper.cpp

-23
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,6 @@ static inline void initSaiRedisCounterEmptyParameter(sai_redis_flex_counter_grou
702702
initSaiRedisCounterEmptyParameter(flex_counter_group_param.stats_mode);
703703
initSaiRedisCounterEmptyParameter(flex_counter_group_param.plugin_name);
704704
initSaiRedisCounterEmptyParameter(flex_counter_group_param.plugins);
705-
initSaiRedisCounterEmptyParameter(flex_counter_group_param.bulk_chunk_size);
706-
initSaiRedisCounterEmptyParameter(flex_counter_group_param.bulk_chunk_size_per_prefix);
707705
}
708706

709707
static inline void initSaiRedisCounterParameterFromString(sai_s8_list_t &sai_s8_list, const std::string &str)
@@ -788,8 +786,6 @@ void setFlexCounterGroupParameter(const string &group,
788786
attr.id = SAI_REDIS_SWITCH_ATTR_FLEX_COUNTER_GROUP;
789787
attr.value.ptr = &flex_counter_group_param;
790788

791-
initSaiRedisCounterEmptyParameter(flex_counter_group_param.bulk_chunk_size);
792-
initSaiRedisCounterEmptyParameter(flex_counter_group_param.bulk_chunk_size_per_prefix);
793789
initSaiRedisCounterParameterFromString(flex_counter_group_param.counter_group_name, group);
794790
initSaiRedisCounterParameterFromString(flex_counter_group_param.poll_interval, poll_interval);
795791
initSaiRedisCounterParameterFromString(flex_counter_group_param.operation, operation);
@@ -869,25 +865,6 @@ void setFlexCounterGroupStatsMode(const std::string &group,
869865
notifySyncdCounterOperation(is_gearbox, attr);
870866
}
871867

872-
void setFlexCounterGroupBulkChunkSize(const std::string &group,
873-
const std::string &bulk_chunk_size,
874-
const std::string &bulk_chunk_size_per_prefix,
875-
bool is_gearbox)
876-
{
877-
sai_attribute_t attr;
878-
sai_redis_flex_counter_group_parameter_t flex_counter_group_param;
879-
880-
attr.id = SAI_REDIS_SWITCH_ATTR_FLEX_COUNTER_GROUP;
881-
attr.value.ptr = &flex_counter_group_param;
882-
883-
initSaiRedisCounterEmptyParameter(flex_counter_group_param);
884-
initSaiRedisCounterParameterFromString(flex_counter_group_param.counter_group_name, group);
885-
initSaiRedisCounterParameterFromString(flex_counter_group_param.bulk_chunk_size, bulk_chunk_size);
886-
initSaiRedisCounterParameterFromString(flex_counter_group_param.bulk_chunk_size_per_prefix, bulk_chunk_size_per_prefix);
887-
888-
notifySyncdCounterOperation(is_gearbox, attr);
889-
}
890-
891868
void delFlexCounterGroup(const std::string &group,
892869
bool is_gearbox)
893870
{

orchagent/saihelper.h

-5
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ void setFlexCounterGroupStatsMode(const std::string &group,
4040
const std::string &stats_mode,
4141
bool is_gearbox=false);
4242

43-
void setFlexCounterGroupBulkChunkSize(const std::string &group,
44-
const std::string &bulk_size,
45-
const std::string &bulk_chunk_size_per_prefix,
46-
bool is_gearbox=false);
47-
4843
void delFlexCounterGroup(const std::string &group,
4944
bool is_gearbox=false);
5045

tests/mock_tests/flexcounter_ut.cpp

-45
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,6 @@ namespace flexcounter_test
131131
}
132132
else
133133
{
134-
if (flexCounterGroupParam->bulk_chunk_size.list != nullptr || flexCounterGroupParam->bulk_chunk_size_per_prefix.list != nullptr)
135-
{
136-
return SAI_STATUS_SUCCESS;
137-
}
138134
mockFlexCounterGroupTable->del(key);
139135
}
140136

@@ -927,47 +923,6 @@ namespace flexcounter_test
927923
consumer->addToSync(entries);
928924
entries.clear();
929925
static_cast<Orch *>(gBufferOrch)->doTask();
930-
931-
if (!gTraditionalFlexCounter)
932-
{
933-
// Verify bulk chunk size fields which can be verified in any combination of parameters.
934-
// We verify it here just for convenience.
935-
consumer = dynamic_cast<Consumer *>(flexCounterOrch->getExecutor(CFG_FLEX_COUNTER_TABLE_NAME));
936-
937-
entries.push_back({"PORT", "SET", {
938-
{"FLEX_COUNTER_STATUS", "enable"},
939-
{"BULK_CHUNK_SIZE", "64"}
940-
}});
941-
consumer->addToSync(entries);
942-
entries.clear();
943-
static_cast<Orch *>(flexCounterOrch)->doTask();
944-
ASSERT_TRUE(flexCounterOrch->m_groupsWithBulkChunkSize.find("PORT") != flexCounterOrch->m_groupsWithBulkChunkSize.end());
945-
946-
entries.push_back({"PORT", "SET", {
947-
{"FLEX_COUNTER_STATUS", "enable"}
948-
}});
949-
consumer->addToSync(entries);
950-
entries.clear();
951-
static_cast<Orch *>(flexCounterOrch)->doTask();
952-
ASSERT_EQ(flexCounterOrch->m_groupsWithBulkChunkSize.find("PORT"), flexCounterOrch->m_groupsWithBulkChunkSize.end());
953-
954-
entries.push_back({"PORT", "SET", {
955-
{"FLEX_COUNTER_STATUS", "enable"},
956-
{"BULK_CHUNK_SIZE_PER_PREFIX", "SAI_PORT_STAT_IF_OUT_QLEN:0;SAI_PORT_STAT_IF_IN_FEC:32"}
957-
}});
958-
consumer->addToSync(entries);
959-
entries.clear();
960-
static_cast<Orch *>(flexCounterOrch)->doTask();
961-
ASSERT_TRUE(flexCounterOrch->m_groupsWithBulkChunkSize.find("PORT") != flexCounterOrch->m_groupsWithBulkChunkSize.end());
962-
963-
entries.push_back({"PORT", "SET", {
964-
{"FLEX_COUNTER_STATUS", "enable"}
965-
}});
966-
consumer->addToSync(entries);
967-
entries.clear();
968-
static_cast<Orch *>(flexCounterOrch)->doTask();
969-
ASSERT_EQ(flexCounterOrch->m_groupsWithBulkChunkSize.find("PORT"), flexCounterOrch->m_groupsWithBulkChunkSize.end());
970-
}
971926
}
972927

973928
// Remove buffer pools

0 commit comments

Comments
 (0)