Reputation: 271
In golang, maps implemented using hash tables .I am using locks of sync package for readinng and writing in maps. Is there any performance impact if 50,000 reqests try to access the map ? What is the order of reading/writing maps? Is it O(1)?
Upvotes: 2
Views: 13882
Reputation: 33593
There are two separate issues here:
An answer can be found in this issue
This doesn't sound like a good idea, but you can never know without benchmarking. You might want to consider sending the map values asynchronously through a buffered channel, if you don't depend on the fact that the map value would be written immediately.
You might also want to check out concurrent-map which is solving a similar problem.
Upvotes: 6