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

proposal: x/sync: add multimap #61939

Closed
DerekTBrown opened this issue Aug 10, 2023 · 3 comments
Closed

proposal: x/sync: add multimap #61939

DerekTBrown opened this issue Aug 10, 2023 · 3 comments

Comments

@DerekTBrown
Copy link

TL;DR; Add a first-class multimap to x/sync

Why do we need a specific primitive for multimap?

  1. standardization - Libraries can more easily inter-operate if there is a standard multimap type. Rust and C++ offer standard multimap implementations, demonstrating the need/demand for this type.
  2. correctness - Implementation of multimap is non-trivial. Providing a standard implementation reduces the risk of bugs introduced by poor multimap implementations.
  3. performance - A multimap structure using existing primitives (eg. maps and slices) is likely to be sub-optimal because of redundant locking. Creating a first-class multimap type allows for a more efficient implementation using unsafe primitives.

Reference implementation:

The following is a reference implementation using existing (map + mutex) primitives:

https://go-review.googlesource.com/c/sync/+/517955

@gopherbot gopherbot added this to the Proposal milestone Aug 10, 2023
@seankhliao
Copy link
Member

seankhliao commented Aug 10, 2023

Can you point to sufficient use of such a data structure in existing, third party code to justify its addition?

Also, please include the specific proposed API here.

@seankhliao seankhliao changed the title proposal: affected/package: x/sync, add multimap proposal: x/sync: add multimap Aug 10, 2023
@ianlancetaylor ianlancetaylor moved this to Incoming in Proposals Aug 10, 2023
@ianlancetaylor
Copy link
Contributor

CC @bcmills

@DerekTBrown
Copy link
Author

I realized there are some issues with this implementation. Will re-open with revisions.

@golang golang locked and limited conversation to collaborators Aug 16, 2024
@rsc rsc removed this from Proposals Aug 29, 2024
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

4 participants