perf: eliminate redundant map lookups in swssPrioNotify and swssOutputNotify#1214
perf: eliminate redundant map lookups in swssPrioNotify and swssOutputNotify#1214xq9mend wants to merge 1 commit into
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
e90d53c to
df9051f
Compare
|
/azpw run Azure.sonic-swss-common |
|
Retrying failed(or canceled) jobs... |
|
/azp run |
|
No Azure DevOps builds found for #1214. |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks! ---Powered by SONiC BuildBot
|
|
/azpw run Azure.sonic-swss-common |
|
Retrying failed(or canceled) jobs... |
|
Retrying failed(or canceled) stages in build 1144010: ✅Stage Test:
|
|
/azpw run Azure.sonic-swss-common |
|
Retrying failed(or canceled) jobs... |
|
Retrying failed(or canceled) stages in build 1144010: ✅Stage Test:
|
…tNotify Both functions called find() to check existence, then at() to retrieve the value — two O(log n) lookups for the success path. Store the iterator from find() and use it directly, halving the lookup cost. Signed-off-by: xq9mend <xq9mend@users.noreply.github.com>
df9051f to
b5f4680
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
The The code change in this PR is correct and unrelated to p4rt. |
Why
swssPrioNotifyandswssOutputNotifyeach perform two map lookups on the success path:find()to check if the key existsat()to retrieve the valueBoth are O(log n) on
std::map, so the success path pays the cost twice unnecessarily.How
Store the iterator returned by
find()and useit->seconddirectly in the else branch, eliminating the second lookup.How to verify
Existing logger unit tests pass. Behavior is identical — only the number of map traversals changes.