Optimize memory orders for weakly ordered architectures.
In `RefCount::Unref()`, `fetch_sub()` with `memory_order_release` rather than
`memory_order_acq_rel`. Then, only in the unexpected path when this was the last
decrement (due to `IsUnique()` called before, this can happen only if another
thread calls `Unref()` at the same time), `atomic_thread_fence()` with
`memory_order_acquire`.
This removes the unnecessary acquire semantics from the expected path.
In `StableDependencyDefault::EnsureAllocatedSlow()`, `compare_exchange_strong()`
with a separate `memory_order_release` for the expected success path and
`memory_order_acquire` for the unexpected failure path (which can happen only
another thread calls `EnsureAllocatd()` at the same time), instead of using
`memory_order_acq_rel` for both.
In the unexpected path there is no change because `compare_exchange_strong()`
implicitly demotes `memory_order_acq_rel` to `memory_order_acquire` there.
This removes the unnecessary acquire semantics from the expected path.
Cosmetics: in `RefCount::{Ref,Unref}()`, replace `if` with `if constexpr`,
and split a complex conditional into separate statements.
PiperOrigin-RevId: 915941386
Riegeli/records is a file format for storing a sequence of string records, typically serialized protocol buffers. It supports dense compression, fast decoding, seeking, detection and optional skipping of data corruption, filtering of proto message fields for even faster decoding, and parallel encoding.
See documentation.
Riegeli file format will only change in a backward compatible way (i.e. future readers will understand current files, but current readers might not understand files using future features).
Riegeli C++ API might change in incompatible ways.