yabeda-resque 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92a9da462531ecfb518643959d19f16b3c1be6a046e007b6b15a5e2d2750d807
4
- data.tar.gz: 534ff3806d35238cc01b55a25b80ab56ba1b654f5922ccf5258a1bc749577261
3
+ metadata.gz: f8679f70e3f362a27c2e217852e5e2ca48718ba66cf4bdf929d57252dfb56726
4
+ data.tar.gz: ce6340bbc3f60d3c20bd6dc23fe09ff43efe44bf71bede21112d6a41905f45d3
5
5
  SHA512:
6
- metadata.gz: 22e5a853e3f3859ad67eeedc58805fd6a2c2f1223aaf4f3ebca0ccc1053e69fe95c33385aa9416c2c9ff5ee2bf7e587ca12605bd63d8ed369dbb9095188481b0
7
- data.tar.gz: '031385be1e5fbf72ea6d80fe1a928d504018b11b604b364f3d5a243db2b4145a26f09ae655712641c239cc75fd7c3537067a3761e7c287d3c6c6518254bcb185'
6
+ metadata.gz: a38fd70482feffcab13f959625a426424f8b79e45cbdd7ceb2bf78b4d3df567f7ea31dd5c6b9339051cea10b0c53f9f9eaf2ca96f2457feee51a359ef8c63a65
7
+ data.tar.gz: 70629efcd1073097faee26feb96eb486a6baed2ebae5e41ac3716d2d67ea750abff78632e7f3c1f28f6d8b65d9e401f0dd25522095ea8259ce232c2c011aa32d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.3.0] - 2026-05-11
4
+ - Improve Performance of delayed job counting (#1, by @top-sigrid)
5
+
3
6
  ## [1.2.0] - 2025-05-16
4
7
  - Add jobs_processing_oldest_age metric with unit as config option
5
8
 
data/README.md CHANGED
@@ -54,7 +54,7 @@ included in the `queue_sizes` metric. Gathering this information can be quite ex
54
54
 
55
55
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
56
56
 
57
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
57
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, commit it, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
58
58
 
59
59
  ## Contributing
60
60
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module Resque
5
- VERSION = "1.2.0"
5
+ VERSION = "1.3.0"
6
6
  end
7
7
  end
data/lib/yabeda/resque.rb CHANGED
@@ -16,6 +16,21 @@ module Yabeda
16
16
  defined?(::Resque::Scheduler)
17
17
  end
18
18
 
19
+ # Pipelined alternative to Resque.count_all_scheduled_jobs from resque-scheduler.
20
+ # The original implementation issues a sequential LLEN call per timestamp, resulting in N round-trips to Redis.
21
+ # This version pipelines LLEN calls in batches to avoid blocking the Redis thread for too long,
22
+ # which is significantly faster when there are many delayed timestamps.
23
+ def count_all_scheduled_jobs_pipelined
24
+ timestamps = ::Resque.redis.zrange(:delayed_queue_schedule, 0, -1)
25
+ return 0 if timestamps.empty?
26
+
27
+ timestamps.each_slice(10_000).sum do |batch|
28
+ ::Resque.redis.pipelined do |pipeline|
29
+ batch.each { |ts| pipeline.llen("delayed:#{ts}") }
30
+ end.sum
31
+ end
32
+ end
33
+
19
34
  def jobs_processing_oldest_age(config)
20
35
  oldest_timestamp = ::Resque.working.map { |worker| worker.job(false)["run_at"] }.min
21
36
  return 0 if oldest_timestamp.nil?
@@ -73,7 +88,7 @@ module Yabeda
73
88
  end
74
89
 
75
90
  if ::Yabeda::Resque.monitor_delayed?
76
- resque.jobs_delayed.set({}, ::Resque.count_all_scheduled_jobs)
91
+ resque.jobs_delayed.set({}, ::Yabeda::Resque.count_all_scheduled_jobs_pipelined)
77
92
  end
78
93
 
79
94
  ::Resque.queue_sizes.each do |queue, size|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yabeda-resque
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josch Bockler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-05-15 00:00:00.000000000 Z
11
+ date: 2026-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: resque