sonic-net / sonic-sairedis

SAI object interface to Redis database, as used in the SONiC project
Other
56 stars 273 forks source link

Do not enter vendor SAI critical section for counter polling/clearing operations #1450

Closed stephenxs closed 2 weeks ago

stephenxs commented 2 weeks ago

What I did

Do not enter the vendor SAI critical section for counter-polling/-clearing operations.

Why I did it

There are two types of threads in syncd:

  1. The syncd main thread in which the create/destroy/set/get SAI APIs are called
  2. Flex counter threads in which counter-polling/-clearing APIs are called

The critical section in vendor SAI was introduced to protect vendors' SAI from being re-entered, which prevents the flex counter threads from running concurrently, and introduces latency for one flex counter thread when it's waiting for the critical section. It is not necessary to enter a section in counter-polling/clearing operations since the objects' state won't be changed in that API.

How I verified it

Run regression test and observe counter-polling performance.

Details if related