Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[qosorch]: Optimizations of qosorch #488

Merged

Conversation

pavel-shirshov
Copy link
Contributor

@pavel-shirshov pavel-shirshov commented Apr 24, 2018

What I did
Optimized qosorch to make it run faster. I'm caching intermediate results, to avoid re-request the information which was already requested from ASIC.

Why I did it
It reduces qosorch working time significantly. For example on the target platform it was reduced by 4 secs.
Here the statistics of SAI requests before and after the change:
Before:

    128 SAI_OBJECT_TYPE_INGRESS_PRIORITY_GROUP - 128 set
    832 SAI_OBJECT_TYPE_PORT                   - 512 get, 320 set
    128 SAI_OBJECT_TYPE_QUEUE                  - 128 set 
   2304 SAI_OBJECT_TYPE_SCHEDULER_GROUP        - 256 set, 2048 get
    256 SAI_OBJECT_TYPE_SWITCH                 - 256 get
   2816 SAI_STATUS_SUCCESS                     - results of get

After:

    128 SAI_OBJECT_TYPE_INGRESS_PRIORITY_GROUP - 128 set
    448 SAI_OBJECT_TYPE_PORT                   - 128 get, 320 set
    128 SAI_OBJECT_TYPE_QUEUE                  - 128 set 
   1024 SAI_OBJECT_TYPE_SCHEDULER_GROUP        - 256 set, 768 get
      0 SAI_OBJECT_TYPE_SWITCH                 - 0 get
    896 SAI_STATUS_SUCCESS                     - results of get

How I verified it
Build and check sairedis.rec. You should see only one get of this attribute from the switch.

Details if related

@pavel-shirshov
Copy link
Contributor Author

I'll update the PR with more changes

@pavel-shirshov pavel-shirshov changed the title [qosorch]: Get the switch attribute just once [qosorch]: Optimizations of qosorch Apr 25, 2018
@pavel-shirshov pavel-shirshov merged commit f939b95 into sonic-net:master Apr 27, 2018
@pavel-shirshov pavel-shirshov deleted the pavelsh/switch_request branch April 27, 2018 19:43
EdenGri pushed a commit to EdenGri/sonic-swss that referenced this pull request Feb 28, 2022
oleksandrivantsiv pushed a commit to oleksandrivantsiv/sonic-swss that referenced this pull request Mar 1, 2023
…ters() (sonic-net#488)

Each time a new counter/attribute type is added to flex counter infrastructure, collectCounters() is tailed with the logic of collecting the stats for the new type. As more and more possible id lists are being added to the flex counter, the collectCounters() member function is becoming bulky to check against all possible id lists, both existing and newly added ones.

Current list is already significantly long---port counters, queue counters, queue attributes, pg counters, pg attributes, and buffer pool counters. And most of them are irrelevant to a particular flex counter instance thread. E.g., For buffer pool watermark thread, only buffer pool counters matter, not the rest, port counters, queue counters, queue attributes, pg counters, pg attributes.
Improvement:

Separate each counter/attribute type to be a member function of FlexCounter with the same function prototype.

Have a data member (unordered_map) to maintain pointers to member functions for each flex counter instance, and install only the essential counter collection member functions at the counter/attribute list set operation.

Choice of data member structure: Originally considered unordered_set with element T to be a pointer to member function. However, the element type does not support a certain operations, and thus can not be taken as a key, but only as a value.
In doing so, we can avoid checking against irrelevant counter/attribute id lists, and keep a fixed size for collectCounters function.

Signed-off-by: Wenda Ni <wenni@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants