Skip to content

Relax atomic operations of update_gauge and increment_counter - #184

Merged
tobz merged 1 commit into
metrics-rs:mainfrom
blt:blt-relaxed_atomics
Mar 16, 2021
Merged

Relax atomic operations of update_gauge and increment_counter#184
tobz merged 1 commit into
metrics-rs:mainfrom
blt:blt-relaxed_atomics

Conversation

@blt

@blt blt commented Mar 15, 2021

Copy link
Copy Markdown
Contributor

This commit relaxes the atomics of the aforementioned functions, removing the sync pressure on machines with large numbers of CPUs or ARM. As the reads of counters and gauges were formerly relaxed I believe this maintains the semantic intentions, though it is now possible for a writer to immediately read and "lose" the write temporarily if the read is done from a different CPU, in the case of the counter.

I noticed this while digging through vectordotdev/vector#6770. I haven't managed to test in our project because of vectordotdev/vector#6412.

Signed-off-by: Brian L. Troutwine brian@troutwine.us

This commit relaxes the atomics of the aforementioned functions, removing the
sync pressure on machines with large numbers of CPUs or ARM. As the reads of
counters and gauges were formerly relaxed I believe this maintains the semantic
intentions, though it is now possible for a writer to immediately read and
"lose" the write temporarily if the read is done from a different CPU, in the
case of the counter.

Signed-off-by: Brian L. Troutwine <brian@troutwine.us>

@tobz tobz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all seems reasonable; just a single spot we need to tweak.

Comment thread metrics-util/src/handle.rs
@tobz
tobz merged commit f28630c into metrics-rs:main Mar 16, 2021
@tobz

tobz commented Mar 16, 2021

Copy link
Copy Markdown
Member

Merged. Thanks for you contribution!

@blt
blt deleted the blt-relaxed_atomics branch March 16, 2021 16:20
mnpw pushed a commit to mnpw/metrics that referenced this pull request Mar 8, 2024
Relax atomic operations of `update_gauge` and `increment_counter`
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