golang/go

sync/atomic: add Uint64Pair

Open

#61,236 opened on Jul 8, 2023

View on GitHub
 (41 comments) (13 reactions) (1 assignee)Go (19,008 forks)batch import
ProposalProposal-Acceptedcompiler/runtimehelp wanted

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

I suggest CAS2 is implemented in the atomic package similar to atomic.align64, operational for hardware that supports it.

possibly also:

  • atomic OR
  • LL/SC Load-link/store-conditional

  • With the 2022 memory model, go1.19 atomics became useful after years of unproductive near-sighted discussions
  • However, wait-free algorithms now use CAS2, ie. 128-bit atomic, which is supported on most cpus but not in Go
  • implementing CAS spinners in lock-free applications produces long thread wait-times or 100% cpu, so wait-free is better: threads are neither suspended or spinning. We will have 100 cores and 100 GiB RAM from Apple soon enough
  • what is desired is a performant wait-free queue and wait-free free-list stack
  • fast-path of wCQ Nikolaev Ravindran 2022 and wfq Yang Mellor-Crummey 2016
  • this would enable an initial thread-pool to have wait-free and allocation-free data sink

darwin-arm64 darwin-amd64 linux-amd64

I think also atomic generics could do with another polish Like this AtomicMax that is more flexible in what underlying integer types and named types can be used: https://github.com/haraldrudell/parl/blob/main/atomic-max.go

  • by inventing align64 only in atomic, 64-bit things must go in atomic

Contributor guide