- New data structure:
UMPSCQueue
#168 - Speed up
LoadAndDelete
andDelete
in case of non-existingMap
key #167 - Parallel
Map
resize #170
UMPSCQueue
is meant to serve as a replacement for a channel. However, crucially, it has infinite capacity. This is a very bad idea in many cases as it means that it never exhibits backpressure. In other words, if nothing is consuming elements from the queue, it will eventually consume all available memory and crash the process. However, there are also cases where this is desired behavior as it means the queue will dynamically allocate more memory to store temporary bursts, allowing producers to never block while the consumer catches up.
From now on, Map
spawns additional goroutines to speed up resizing the hash table. This can be disabled when creating a Map
with the new WithSerialResize
setting:
m := xsync.NewMap[int, int](xsync.WithSerialResize())
// resize will take place on the current goroutine only
for i := 0; i < 10000; i++ {
m.Store(i, i)
}
Thanks @PapaCharlie and @llxisdsh for the contributions!