Skip to content

Commit e82f8c2

Browse files
committed
Revert "Optimize counter polling interval by making it more accurate (sonic-net#3500)"
This reverts commit 337c9a1.
1 parent ca017d0 commit e82f8c2

6 files changed

Lines changed: 4 additions & 135 deletions

File tree

orchagent/flexcounterorch.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,6 @@ void FlexCounterOrch::doTask(Consumer &consumer)
154154
}
155155
}
156156
}
157-
else if (field == BULK_CHUNK_SIZE_FIELD)
158-
{
159-
bulk_chunk_size = value;
160-
}
161-
else if (field == BULK_CHUNK_SIZE_PER_PREFIX_FIELD)
162-
{
163-
bulk_chunk_size_per_counter = value;
164-
}
165157
else if(field == FLEX_COUNTER_STATUS_FIELD)
166158
{
167159
// Currently, the counters are disabled for polling by default
@@ -271,19 +263,6 @@ void FlexCounterOrch::doTask(Consumer &consumer)
271263
SWSS_LOG_NOTICE("Unsupported field %s", field.c_str());
272264
}
273265
}
274-
275-
if (!bulk_chunk_size.empty() || !bulk_chunk_size_per_counter.empty())
276-
{
277-
m_groupsWithBulkChunkSize.insert(key);
278-
setFlexCounterGroupBulkChunkSize(flexCounterGroupMap[key],
279-
bulk_chunk_size.empty() ? "NULL" : bulk_chunk_size,
280-
bulk_chunk_size_per_counter.empty() ? "NULL" : bulk_chunk_size_per_counter);
281-
}
282-
else if (m_groupsWithBulkChunkSize.find(key) != m_groupsWithBulkChunkSize.end())
283-
{
284-
setFlexCounterGroupBulkChunkSize(flexCounterGroupMap[key], "NULL", "NULL");
285-
m_groupsWithBulkChunkSize.erase(key);
286-
}
287266
}
288267

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

orchagent/flexcounterorch.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class FlexCounterOrch: public Orch
6969
Table m_bufferQueueConfigTable;
7070
Table m_bufferPgConfigTable;
7171
Table m_deviceMetadataConfigTable;
72-
std::unordered_set<std::string> m_groupsWithBulkChunkSize;
7372
std::unique_ptr<SelectableTimer> m_delayTimer;
7473
std::unique_ptr<Executor> m_delayExecutor;
7574
};

orchagent/pfc_detect_mellanox.lua

100755100644
Lines changed: 4 additions & 40 deletions
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

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,6 @@ static inline void initSaiRedisCounterEmptyParameter(sai_redis_flex_counter_grou
851851
initSaiRedisCounterEmptyParameter(flex_counter_group_param.stats_mode);
852852
initSaiRedisCounterEmptyParameter(flex_counter_group_param.plugin_name);
853853
initSaiRedisCounterEmptyParameter(flex_counter_group_param.plugins);
854-
initSaiRedisCounterEmptyParameter(flex_counter_group_param.bulk_chunk_size);
855-
initSaiRedisCounterEmptyParameter(flex_counter_group_param.bulk_chunk_size_per_prefix);
856854
}
857855

858856
static inline void initSaiRedisCounterParameterFromString(sai_s8_list_t &sai_s8_list, const std::string &str)
@@ -937,8 +935,6 @@ void setFlexCounterGroupParameter(const string &group,
937935
attr.id = SAI_REDIS_SWITCH_ATTR_FLEX_COUNTER_GROUP;
938936
attr.value.ptr = &flex_counter_group_param;
939937

940-
initSaiRedisCounterEmptyParameter(flex_counter_group_param.bulk_chunk_size);
941-
initSaiRedisCounterEmptyParameter(flex_counter_group_param.bulk_chunk_size_per_prefix);
942938
initSaiRedisCounterParameterFromString(flex_counter_group_param.counter_group_name, group);
943939
initSaiRedisCounterParameterFromString(flex_counter_group_param.poll_interval, poll_interval);
944940
initSaiRedisCounterParameterFromString(flex_counter_group_param.operation, operation);
@@ -1018,25 +1014,6 @@ void setFlexCounterGroupStatsMode(const std::string &group,
10181014
notifySyncdCounterOperation(is_gearbox, attr);
10191015
}
10201016

1021-
void setFlexCounterGroupBulkChunkSize(const std::string &group,
1022-
const std::string &bulk_chunk_size,
1023-
const std::string &bulk_chunk_size_per_prefix,
1024-
bool is_gearbox)
1025-
{
1026-
sai_attribute_t attr;
1027-
sai_redis_flex_counter_group_parameter_t flex_counter_group_param;
1028-
1029-
attr.id = SAI_REDIS_SWITCH_ATTR_FLEX_COUNTER_GROUP;
1030-
attr.value.ptr = &flex_counter_group_param;
1031-
1032-
initSaiRedisCounterEmptyParameter(flex_counter_group_param);
1033-
initSaiRedisCounterParameterFromString(flex_counter_group_param.counter_group_name, group);
1034-
initSaiRedisCounterParameterFromString(flex_counter_group_param.bulk_chunk_size, bulk_chunk_size);
1035-
initSaiRedisCounterParameterFromString(flex_counter_group_param.bulk_chunk_size_per_prefix, bulk_chunk_size_per_prefix);
1036-
1037-
notifySyncdCounterOperation(is_gearbox, attr);
1038-
}
1039-
10401017
void delFlexCounterGroup(const std::string &group,
10411018
bool is_gearbox)
10421019
{

orchagent/saihelper.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ void setFlexCounterGroupStatsMode(const std::string &group,
3939
const std::string &stats_mode,
4040
bool is_gearbox=false);
4141

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

tests/mock_tests/flexcounter_ut.cpp

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ namespace flexcounter_test
111111
}
112112
else
113113
{
114-
if (flexCounterGroupParam->bulk_chunk_size.list != nullptr || flexCounterGroupParam->bulk_chunk_size_per_prefix.list != nullptr)
115-
{
116-
return SAI_STATUS_SUCCESS;
117-
}
118114
mockFlexCounterGroupTable->del(key);
119115
}
120116

@@ -855,47 +851,6 @@ namespace flexcounter_test
855851
consumer->addToSync(entries);
856852
entries.clear();
857853
static_cast<Orch *>(gBufferOrch)->doTask();
858-
859-
if (!gTraditionalFlexCounter)
860-
{
861-
// Verify bulk chunk size fields which can be verified in any combination of parameters.
862-
// We verify it here just for convenience.
863-
consumer = dynamic_cast<Consumer *>(flexCounterOrch->getExecutor(CFG_FLEX_COUNTER_TABLE_NAME));
864-
865-
entries.push_back({"PORT", "SET", {
866-
{"FLEX_COUNTER_STATUS", "enable"},
867-
{"BULK_CHUNK_SIZE", "64"}
868-
}});
869-
consumer->addToSync(entries);
870-
entries.clear();
871-
static_cast<Orch *>(flexCounterOrch)->doTask();
872-
ASSERT_TRUE(flexCounterOrch->m_groupsWithBulkChunkSize.find("PORT") != flexCounterOrch->m_groupsWithBulkChunkSize.end());
873-
874-
entries.push_back({"PORT", "SET", {
875-
{"FLEX_COUNTER_STATUS", "enable"}
876-
}});
877-
consumer->addToSync(entries);
878-
entries.clear();
879-
static_cast<Orch *>(flexCounterOrch)->doTask();
880-
ASSERT_EQ(flexCounterOrch->m_groupsWithBulkChunkSize.find("PORT"), flexCounterOrch->m_groupsWithBulkChunkSize.end());
881-
882-
entries.push_back({"PORT", "SET", {
883-
{"FLEX_COUNTER_STATUS", "enable"},
884-
{"BULK_CHUNK_SIZE_PER_PREFIX", "SAI_PORT_STAT_IF_OUT_QLEN:0;SAI_PORT_STAT_IF_IN_FEC:32"}
885-
}});
886-
consumer->addToSync(entries);
887-
entries.clear();
888-
static_cast<Orch *>(flexCounterOrch)->doTask();
889-
ASSERT_TRUE(flexCounterOrch->m_groupsWithBulkChunkSize.find("PORT") != flexCounterOrch->m_groupsWithBulkChunkSize.end());
890-
891-
entries.push_back({"PORT", "SET", {
892-
{"FLEX_COUNTER_STATUS", "enable"}
893-
}});
894-
consumer->addToSync(entries);
895-
entries.clear();
896-
static_cast<Orch *>(flexCounterOrch)->doTask();
897-
ASSERT_EQ(flexCounterOrch->m_groupsWithBulkChunkSize.find("PORT"), flexCounterOrch->m_groupsWithBulkChunkSize.end());
898-
}
899854
}
900855

901856
// Remove buffer pools

0 commit comments

Comments
 (0)