Ruby version: All
Sidekiq - Free, all versions
Do you ever try to add one queue with 10000000000 weight?
You will probably run out of memory...
I propose to change options[:queues] from ['queue', 'queue', 'queue'...repeat n times] to { 'queue' => n }
Sidekiq does queues.shuffle.uniq to sort queues based on weights.
This algorithm has O(N) complexity where N is sum of weights
I propose to do sorting of hash queues.to_a.sort_by { |_queue, weight| -Math.log(rand) / weight }
This math formula i found here
This algorithm has also O(N) complexity but N is number of queues, which is usually much less then sum of weights.
Old algorithm is still faster for small weights.
But if user can specify weights with two zeros, new approach will be better
What do you think about such changes, will you accept a PR?
I'm not interested in this change. It's a minor issue and not worth the effort to try and fix. Don't use large weights.
The documentation is not meant to cover every single edge case and possible issue. If I say that, then I need to define "what is large?", why it is a problem, etc.