You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a large map of IDs -> items, some fraction of those items is in a ready state. I'm using a set of IDs to pick the next ready item and remove it from the ready-set.
Having a way to extract a random item from a set would be useful and likely faster.
Random sampling would avoid the multi-step, non-atomic approach of first iterating to find an ID, copying it, then removing it from the set, it could instead remove an item under a single write lock.
When multiple threads try this concurrently they'll collide on trying to remove the same ID (since the iterators always start at shard 0) and the other threads will have to retry
Random sampling could optimistically attempt try-locking some shards before blocking since the order doesn't matter
The text was updated successfully, but these errors were encountered:
I have a large map of IDs -> items, some fraction of those items is in a ready state. I'm using a set of IDs to pick the next ready item and remove it from the ready-set.
Having a way to extract a random item from a set would be useful and likely faster.
When multiple threads try this concurrently they'll collide on trying to remove the same ID (since the iterators always start at shard 0) and the other threads will have to retry
The text was updated successfully, but these errors were encountered: