Skip to content

doc: update Go memory model #50859

@rsc

Description

@rsc

In June 2021 I posted a series of articles about memory models, ending with an article about changes I thought we should make to the Go memory model. See https://research.swtch.com/mm especially https://research.swtch.com/gomm.

Then I opened a GitHub Discussion to discuss these changes; see #47141.

Based on that discussion, I propose the following concrete changes to the memory model:

  • Document Go's overall approach.
  • Document that multiword races can cause crashes.
  • Document happens-before for runtime.SetFinalizer.
  • Document (or link to) happens-before for more sync types.
  • Document happens-before for sync/atomic, matching C++ sequentially consistent atomics (and Java, JavaScript, Rust, Swift, C, ...)
  • Document disallowed compiler optimizations.

The exact details can be viewed in pending CLs prepared for concreteness, in particular CL 381315 (memory model) and CL 381316 (library docs).

I have filed a separate proposal - #50860 - for another item that arose during that discussion, namely adding typed atomic values to sync/atomic.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions