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

AtomicBuffer opaque methods #313

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pveentjer
Copy link
Contributor

@pveentjer pveentjer commented Jan 15, 2025

Added opaque operations to AtomicBuffer for int/long. An opaque loads/stores provides atomicity and visibility, but it doesn't provide any ordering guarantees beyond coherence. So it doesn't order loads/stores to different addresses (doesn't provide consistency), only to its own address (coherence). Opaque is very much like a C-style volatile and can be used in the same situation as the C++ memory_order_relaxed.

For more info see:

https://gee.cs.oswego.edu/dl/html/j9mm.html

Opaque operations are great for performance counters or progress indicators and provide the least amount of overhead on the CPU (all modern CPUs are coherent); especially ISA's with a weak memory model like ARM or RISC-V. It provides less value on the X86 since every store is a release store and every load is an acquire load.

Opaque is great for single writer multiple reader scenario's.

Idea:
Instead of using the naming 'opaque', the name 'relaxed' could be an idea. With relaxed coming from memory_order_relaxed.

@pveentjer pveentjer requested a review from vyazelenko January 15, 2025 07:53
@pveentjer pveentjer force-pushed the feature/atomicbuffer-opaque branch 3 times, most recently from 5b2ef04 to 4b2f430 Compare January 15, 2025 08:59
@pveentjer pveentjer changed the title AtomicBuffer opaque operations [DONT MERGE] AtomicBuffer opaque operations Jan 16, 2025
@pveentjer pveentjer changed the title [DONT MERGE] AtomicBuffer opaque operations AtomicBuffer opaque operations Jan 19, 2025
@pveentjer pveentjer changed the title AtomicBuffer opaque operations AtomicBuffer opaque methods Jan 20, 2025
@vyazelenko
Copy link
Contributor

Has a merge conflict.

Added opaque operations to AtomicBuffer. An opaque operation
provides atomicity and visibility, but it doesn't provide
any ordering guarantees beyond coherence. So it doesn't
order loads/stores to different addresses, only to its
own address.

Opaque operations are great for performance counters or
progress indicators and provide the least amount of overhead
on the CPU (all modern CPUs are coherent); especially CPUs with
a weak memory model like ARM or RISC-V.
@pveentjer pveentjer force-pushed the feature/atomicbuffer-opaque branch from 4b2f430 to 56f8038 Compare February 2, 2025 06:35
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