Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: documentation for Map is inadequate #21587

Closed
robpike opened this issue Aug 24, 2017 · 6 comments
Closed

sync: documentation for Map is inadequate #21587

robpike opened this issue Aug 24, 2017 · 6 comments

Comments

@robpike
Copy link
Contributor

robpike commented Aug 24, 2017

What's there is correct but unhelpful. How does it differ from the map type? When should it be used? When should it not be used? What are its performance characteristics.

I think a newcomer would find what's there inadequate to understand what it's for.

@bcmills
Copy link
Contributor

bcmills commented Aug 24, 2017

See also #20973.

@bcmills
Copy link
Contributor

bcmills commented Aug 24, 2017

I believe these points are already addressed in the current documentation, but it's always difficult for someone close to the implementation to document it from a newcomer's perspective. Concrete suggestions would be helpful.

How does it differ from the map type?

"It is safe for multiple goroutines to call a Map's methods concurrently."

When should it be used? When should it not be used? What are its performance characteristics.

"It is optimized for use in concurrent loops with keys that are stable over time, and either few steady-state stores, or stores localized to one goroutine per key."

"For use cases that do not share these attributes, it will likely have comparable or worse performance and worse type safety than an ordinary map paired with a read-write mutex."

@robpike
Copy link
Contributor Author

robpike commented Aug 24, 2017

I think it's odd enough it deserves a little textual example, like "accessing a mostly read-only map under high concurrency" or something along those lines." You hint at this but in an operational way rather than an illustrative one.

@dsnet dsnet added this to the Go1.10 milestone Sep 1, 2017
@yiv
Copy link

yiv commented Oct 21, 2017

how to understand

For use cases that do not share these attributes, it will likely have comparable or worse performance and worse type safety than an ordinary map paired with a read-write mutex.

@ianlancetaylor
Copy link
Contributor

@yiv We don't use the issue tracker to ask questions. Please see https://golang.org/wiki/Questions. Thanks.

@gopherbot
Copy link

Change https://golang.org/cl/83796 mentions this issue: sync: document when and when not to use Map

@golang golang locked and limited conversation to collaborators Jan 4, 2019
@rsc rsc unassigned bcmills Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants