mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Minimize scheduler load on Redis, closes #4882
This commit is contained in:
parent
da15276b77
commit
ed73ed0d25
2 changed files with 12 additions and 1 deletions
|
@ -2,6 +2,11 @@
|
|||
|
||||
[Sidekiq Changes](https://github.com/mperham/sidekiq/blob/master/Changes.md) | [Sidekiq Pro Changes](https://github.com/mperham/sidekiq/blob/master/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/mperham/sidekiq/blob/master/Ent-Changes.md)
|
||||
|
||||
HEAD
|
||||
---------
|
||||
|
||||
- Minimize scheduler load on Redis at scale [#4882]
|
||||
|
||||
6.2.1
|
||||
---------
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ module Sidekiq
|
|||
@sleeper = ConnectionPool::TimedStack.new
|
||||
@done = false
|
||||
@thread = nil
|
||||
@count_calls = 0
|
||||
end
|
||||
|
||||
# Shut down this instance, will pause until the thread is dead.
|
||||
|
@ -152,8 +153,13 @@ module Sidekiq
|
|||
end
|
||||
|
||||
def process_count
|
||||
pcount = Sidekiq::ProcessSet.new.size
|
||||
# The work buried within Sidekiq::ProcessSet#cleanup can be
|
||||
# expensive at scale. Cut it down by 90% with this counter.
|
||||
# NB: This method is only called by the scheduler thread so we
|
||||
# don't need to worry about the thread safety of +=.
|
||||
pcount = Sidekiq::ProcessSet.new(@count_calls % 10 == 0).size
|
||||
pcount = 1 if pcount == 0
|
||||
@count_calls += 1
|
||||
pcount
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue