Go: Proposal: Atomic maps

Created on 9 Sep 2016  ·  6Comments  ·  Source: golang/go

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

1.6.2, 1.7.0

What operating system and processor architecture are you using (go env)?

some i386, some amd64. ubuntu 16.04, centos 7, fedora 24.

What did you do?

Writing an embedded key-value storage.

What did you expect to see?

Built-in thread-safe maps or sync/atomic methods for concurrent maps access without blocking whole map.

What did you see instead?

No thread-safe maps and no sync/atomic methods for concurrent maps access.

Some kind of dup #1682.
Also, I know about this note. If it impossible to built in thread-safe maps without performance issues, then we can built-in some methods in sync/atomic.

FrozenDueToAge

Most helpful comment

We will not be supporting concurrent write+write or read+write map updates in the standard library, in any package.

We will not support them in our house,
We will not support them with your mouse.
We will not support them here or there,
We will not support them anywhere.
We kinda support them, in an atomic.Value box,
We will not support them in Firefox.
We will not support them in a car, ... (please, no unsafe in automotive systems..)

All 6 comments

As you've found, this has been considered, rejected, re-proposed, rejected, etc in the past.

It's not going to be changing at this point.

Note that it's perfectly safe to access maps concurrently from multiple goroutines, as long as all the goroutines are reading. Only once you need to mutate something do you need to grab an exclusive lock. If you need to concurrently update items, you can make your map values be pointers, and have mutexes or atomics inside your values.

But #1682 says only about built-in thread-safe maps, not about sync/atomic upgrade.
And sync/atomic upgrade will be useful and save performance on current level.

Then #17043 is about saying no to sync/atomic also.

Ok, if it impossible to do in this package, is it possible to do it in any standard Go package?

We will not be supporting concurrent write+write or read+write map updates in the standard library, in any package.

We will not support them in our house,
We will not support them with your mouse.
We will not support them here or there,
We will not support them anywhere.
We kinda support them, in an atomic.Value box,
We will not support them in Firefox.
We will not support them in a car, ... (please, no unsafe in automotive systems..)

Yet you support them in Go 1.9. 😂

Was this page helpful?
0 / 5 - 0 ratings