-
Notifications
You must be signed in to change notification settings - Fork 0
draft: Skip poll based on buffer fullness #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -429,6 +429,39 @@ def run | |||||||||||||
|
|
||||||||||||||
| locker.stop! | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| it "should skip polling if the buffer is sufficiently full" do | ||||||||||||||
| ids = 12.times.map { BlockJob.enqueue(job_options: { priority: 100 }).que_attrs[:id] } | ||||||||||||||
|
|
||||||||||||||
| locker_settings[:worker_priorities] = [100, 100, 100] | ||||||||||||||
| locker_settings[:maximum_buffer_size] = 8 | ||||||||||||||
| locker_settings[:skip_poll_when_buffer_above_threshold] = 0.75 | ||||||||||||||
|
|
||||||||||||||
| locker | ||||||||||||||
| 3.times { $q1.pop } | ||||||||||||||
|
|
||||||||||||||
| # Should have polled once | ||||||||||||||
| locker_polled_events = internal_messages(event: 'poller_polled') | ||||||||||||||
| assert_equal 1, locker_polled_events.size | ||||||||||||||
|
|
||||||||||||||
| # Should have locked first 11 only because there are 8 buffer slots and 3 open workers | ||||||||||||||
| assert_equal ids[0...11], locked_ids | ||||||||||||||
|
|
||||||||||||||
| # Pretend to have worked 1 job to drop buffer to 7/8 full, should skip polling | ||||||||||||||
| $q2.push nil | ||||||||||||||
| sleep_until do | ||||||||||||||
| locker_polling_skipped_events = internal_messages(event: 'locker_polling_skipped') | ||||||||||||||
| locker_polling_skipped_events.any? | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| # No new polling events should have occurred | ||||||||||||||
| locker_polled_events = internal_messages(event: 'poller_polled') | ||||||||||||||
| assert_equal 1, locker_polled_events.size | ||||||||||||||
|
|
||||||||||||||
| 3.times { $q2.push nil } | ||||||||||||||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No idea what it does, but 🙈 since it hangs without it and 5 other tests also have it 🤷♂️ I'm going to follow the existing pattern and resist shaving this yak 🙂 Probably something to do with this mutex Line 215 in 1d66a70
push signals Lines 248 to 252 in 1d66a70
|
||||||||||||||
|
|
||||||||||||||
| locker.stop! | ||||||||||||||
| end | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| describe "when receiving a NOTIFY of a new job" do | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is 0..11 12 or 11? I think it is 12 right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..vs...This spec is hugely
copy-pastedinspired by the one aboveque/spec/que/locker_spec.rb
Lines 422 to 423 in a58d350