Skip to content

perf: eliminate redundant map lookups in swssPrioNotify and swssOutputNotify#1214

Open
xq9mend wants to merge 1 commit into
sonic-net:masterfrom
xq9mend:fix/logger-single-map-lookup
Open

perf: eliminate redundant map lookups in swssPrioNotify and swssOutputNotify#1214
xq9mend wants to merge 1 commit into
sonic-net:masterfrom
xq9mend:fix/logger-single-map-lookup

Conversation

@xq9mend

@xq9mend xq9mend commented Jun 20, 2026

Copy link
Copy Markdown

Why

swssPrioNotify and swssOutputNotify each perform two map lookups on the success path:

  1. find() to check if the key exists
  2. at() to retrieve the value

Both are O(log n) on std::map, so the success path pays the cost twice unnecessarily.

How

Store the iterator returned by find() and use it->second directly 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.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@xq9mend xq9mend force-pushed the fix/logger-single-map-lookup branch from e90d53c to df9051f Compare June 20, 2026 07:03
@xq9mend

xq9mend commented Jun 20, 2026

Copy link
Copy Markdown
Author

/azpw run Azure.sonic-swss-common

@mssonicbld

Copy link
Copy Markdown
Collaborator

⚠️ Notice: /azpw run only runs failed jobs now. If you want to trigger a whole pipline run, please rebase your branch or close and reopen the PR.
💡 Tip: You can also use /azpw retry to retry failed jobs directly.

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@mssonicbld

Copy link
Copy Markdown
Collaborator

No Azure DevOps builds found for #1214.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

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

@xq9mend

xq9mend commented Jun 20, 2026

Copy link
Copy Markdown
Author

/azpw run Azure.sonic-swss-common

@mssonicbld

Copy link
Copy Markdown
Collaborator

⚠️ Notice: /azpw run only runs failed jobs now. If you want to trigger a whole pipline run, please rebase your branch or close and reopen the PR.
💡 Tip: You can also use /azpw retry to retry failed jobs directly.

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) stages in build 1144010:

✅Stage Test:

  • Job vstest: retried.

@xq9mend

xq9mend commented Jun 21, 2026

Copy link
Copy Markdown
Author

/azpw run Azure.sonic-swss-common

@mssonicbld

Copy link
Copy Markdown
Collaborator

⚠️ Notice: /azpw run only runs failed jobs now. If you want to trigger a whole pipline run, please rebase your branch or close and reopen the PR.
💡 Tip: You can also use /azpw retry to retry failed jobs directly.

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) stages in build 1144010:

✅Stage Test:

  • Job vstest: retried.

…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>
@xq9mend xq9mend force-pushed the fix/logger-single-map-lookup branch from df9051f to b5f4680 Compare June 21, 2026 13:41
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@xq9mend

xq9mend commented Jun 21, 2026

Copy link
Copy Markdown
Author

The Test vstest failure is a systemic CI issue unrelated to this PR. The p4rt test group in sonic-swss/tests/p4rt/ is failing across all sonic-swss-common PRs (exit code 123, zero tests passing) due to a mismatch between the latest sonic-swss master test code and the pre-built docker-sonic-vs image. This affects every open sonic-swss-common PR right now — see #1211, #1212, #1213, #1214 all showing the same failure.

The code change in this PR is correct and unrelated to p4rt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants