Skip to content

Use relaxed ordering for external stream counters#1176

Open
BharatDeva wants to merge 1 commit into
timeplus-io:developfrom
BharatDeva:fix/external-stream-counter-relaxed-ordering
Open

Use relaxed ordering for external stream counters#1176
BharatDeva wants to merge 1 commit into
timeplus-io:developfrom
BharatDeva:fix/external-stream-counter-relaxed-ordering

Conversation

@BharatDeva
Copy link
Copy Markdown

PR checklist:

  • Did you run ClangFormat? Not available in this local environment; this header-only change keeps the existing one-line method style and git diff --check is clean.
  • Did you separate headers to a different section in existing community code base? Not applicable, no new headers were added.
  • Did you surround proton: starts/ends for new code in existing community code base? Not applicable, this updates Proton-owned code only.

Please write user-readable short description of the changes:

Fixes #488.

ExternalStreamCounter is used for metrics counters. The reset/read methods already use std::memory_order_relaxed, but add, set, and getCounters() snapshot operations were still using the default sequentially consistent atomic operations.

This PR makes those counter-only operations explicit relaxed atomics as well:

  • fetch_add(..., std::memory_order_relaxed) for counter increments
  • store(..., std::memory_order_relaxed) for setter methods
  • load(std::memory_order_relaxed) for the metrics snapshot map

Validation performed locally:

git diff --check
# clean
g++ -std=c++20 -Isrc -Ibase -c /mnt/c/Users/bhara/AppData/Local/Temp/proton_counter_check.cpp -o /tmp/proton_counter_check.o
# passed

ExternalStreamCounter metrics are plain counters and do not publish or order other data. Use explicit std::memory_order_relaxed for add, set, and snapshot operations to match the existing reset/read methods and avoid unnecessary sequential consistency barriers.

Fixes timeplus-io#488.

Signed-off-by: BharatDeva <278575558+BharatDeva@users.noreply.github.com>
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@yokofly
Copy link
Copy Markdown
Collaborator

yokofly commented May 18, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@yokofly
Copy link
Copy Markdown
Collaborator

yokofly commented May 18, 2026

// edit v1: assign->check

@BharatDeva
Thanks, LGTM.
The change is trivial. Can you check the CLA? as #1176 (comment)

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

use std::memory_order_relaxed for external stream metrics std::atomic counter.

3 participants