bytecodealliance / bytecodealliance/wasmtime

Support different atomic ordering guarantees in Cranelift

Open
#7,722 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 18h
Merged PRs (30d)
126

Description

#### Feature

Cranelift has instructions for atomic operations such as `atomic_load` and `atomic_store`. These instructions don't give control over the ordering guarantees of the atomic operations. Instead, the documentation states that the operations are always sequentially consistent.

For many operations, sequential consistency is _way_ overkill. For example, if you just have a counter that is incremented by a bunch of threads, and occasionally you just want to see if it's greater than `N`, relaxed ordering is more than enough.

#### Benefit

Depending on the needs of the user, control over the atomic ordering guarantees can lead to better performance, especially on platforms that don't already have strong ordering guarantees such as x86.

#### Implementation

I'm not familiar with the Cranelift internals, so I can't answer this section.

#### Alternatives

One could simply stomach the cost of sequential consistency, but I doubt this will work in the long term.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.