Skip to content

Commit ac9782f

Browse files
authored
Merge pull request sonic-net#73 from rupesh-k/rate_counter_util_update
Update SAI changes to retrieve accurate rate counters
2 parents d6d0822 + 33d1b9c commit ac9782f

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

system/Counters_Rate_Utilization_Load_Interval_Support.md

+30-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
* [3.1 Overview](#31-overview)
2626
* [3.1.1 Orchagent](#311-orchagent)
2727
* [3.1.2 SYNCD](#312-syncd)
28-
* [3.1.3 Mgmt-framework](#313-mgmt-framework)
28+
* [3.1.3 SAI](#313-sai)
29+
* [3.1.4 Mgmt-framework](#314-mgmt-framework)
2930
* [3.2 DB Changes](#32-db-changes)
3031
* [3.2.1 CONFIG DB](#321-config-db)
3132
* [3.2.2 APP DB](#322-app-db)
@@ -130,7 +131,7 @@ Queue counters are fetched every 10 seconds, so the load interval can only be mu
130131

131132
SYNCD flex counter thread fetches the interface and queue counters from SAI and updates the COUNTERS DB.
132133
When load interval is set, then thread caches the counters and after every load interval, will generate the interface utilization counters and update the new fields to same COUNTERS DB.
133-
134+
Micro-second timestamp after generating rate counters is cached and used for next rate counter calculations.
134135

135136
```
136137
// stats has current counters read from SAI
@@ -150,6 +151,8 @@ if (load_interval < poll_interval)
150151
// This logic is called every load interval.
151152
// counter overflow will be handled.
152153
154+
// In 3.1.0 release, load_divisor is used for rate calculations
155+
153156
# Interface IN counters
154157
current = stats[SAI_PORT_STAT_IF_IN_UCAST_PKTS] + stats[SAI_PORT_STAT_IF_IN_NON_UCAST_PKTS];
155158
prev = cache[SAI_PORT_STAT_IF_IN_PKTS]
@@ -166,6 +169,10 @@ BPS = ((stats[SAI_PORT_STAT_IF_IN_OCTETS] - cache[SAI_PORT_STAT_IF_IN_OCTETS]) /
166169
bps = BPS << 3
167170
utilization = (bps/port-speed)
168171
172+
// In 3.1.1 releases, micro second timestamp is cached and used for rate calculations.
173+
curr_time = get_millisecond_time();
174+
load_divisor = curr_time - prev_time;
175+
169176
Queue Counters
170177
171178
current = stats[SAI_QUEUE_STAT_PACKETS]
@@ -178,6 +185,27 @@ bps = BPS << 3
178185
179186
```
180187

188+
### 3.1.3 SAI
189+
190+
```
191+
3.1.0 Release:
192+
All counters are read from cache and there will be some deviation with actual traffic on ports.
193+
So the rate counters will show some deviation around 2-3% compared to actual traffic rate.
194+
195+
3.1.1 Release:
196+
Following counters are modified to retreive real time counters to get acurate traffic rate.
197+
SAI_PORT_STAT_IF_IN_OCTETS,
198+
SAI_PORT_STAT_IF_IN_UCAST_PKTS,
199+
SAI_PORT_STAT_IF_IN_NON_UCAST_PKTS,
200+
SAI_PORT_STAT_IF_OUT_OCTETS,
201+
SAI_PORT_STAT_IF_OUT_UCAST_PKTS,
202+
SAI_PORT_STAT_IF_OUT_NON_UCAST_PKTS,
203+
204+
```
205+
206+
To be updated by DELL
207+
The transformer code fetches the new counters and shares it to the client.
208+
181209
### 3.1.3 Mgmt-framework
182210
To be updated by DELL
183211
The transformer code fetches the new counters and shares it to the client.

0 commit comments

Comments
 (0)