-
Notifications
You must be signed in to change notification settings - Fork 897
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
MiqQueue - remove MiqWorker lookup #14620
Conversation
app/models/miq_queue.rb
Outdated
else | ||
msg.update_attributes!(:state => STATE_DEQUEUE, :handler => w) | ||
end | ||
w = MiqWorker.server_scope.find_by(:pid => Process.pid) || MiqServer.my_server |
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.
Maybe call it handler
instead of w
in a second commit?
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.
I like that better - BUT, after looking at MiqQueue.get
I have another optimization here :)
a246ca9
to
c340673
Compare
Checked commits kbrock/manageiq@a568b74~...c340673 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
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.
👍
@@ -267,6 +267,8 @@ def self.start_worker(*params) | |||
w | |||
end | |||
|
|||
cache_with_timeout(:my_worker) { server_scope.find_by(:pid => Process.pid) } |
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.
@kbrock what happens with subclasses that call my_worker
? MiqGenericWorker.my_worker
as an example. Is it sharing a class variable or is it not shared?
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.
It might be weird if we're in a priority worker process and MiqGenericWorker.my_worker
returned a MiqPriorityWorker
row.
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.
I think this is ok, but it's kinda weird if subclasses can return rows of not of it's type.
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.
Will multiple workers run on the same pid
?
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.
@kbrock no, I guess what I'm saying is it doesn't really make sense at the subclass level. We only want this on MiqWorker and not be inherited. I'm fine with it, just curious. I wasn't sure if you tried it out.
For
MiqQuery.get
, we perform an unneeded worker lookup, which is always the same for a given process.comments
count#before-1
count#after-5
TMI
I highlighted the
SELECT
which is present before but not after.comments
count#after-1
.SELECT COUNT(count_column)
.SELECT "miq_queue".*
.SELECT "miq_workers".*
.BEGIN
.UPDATE "miq_queue" SET "state" = 'dequeue', "handler_id" = 1, "handler_type" = 'MiqServer', "updated_on" = .{28}, "lock_version" = 1
.COMMIT
The numbers I collected for this one were a little less consistent, but make they do show the trend
comments
count#before-1
count#before-2
count#before-3
count#before-4
comments
count#after-1
count#after-2
count#after-3
count#after-4
count#after-5