(maint) Speedup the tagging method (#422)

* (maint) Speedup the tagging method
While looking at the instrumentation data for the ABS queue processor,
I noticed a lot of time spent in the HTTP PUT method, which in the code
was easy to isolate, as it is only used via the vmpooler tagging functions
ie the API /vm/foobar/ with 'tag' key-value pairs.
While I'm not sure the original hset() make sense to me, there was an easy
way to speed them up by using pipelined. I would expect a very good speed
increase with this turned on.

* tag rubocop to <1.0 because the 1.0 version returns 130 new offenses
This commit is contained in:
Samuel 2020-10-23 11:40:11 -05:00 committed by GitHub
parent 063a6f6d53
commit 0a323f6052
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -114,11 +114,13 @@ module Vmpooler
end end
def export_tags(backend, hostname, tags) def export_tags(backend, hostname, tags)
tags.each_pair do |tag, value| backend.pipelined do
next if value.nil? or value.empty? tags.each_pair do |tag, value|
next if value.nil? or value.empty?
backend.hset('vmpooler__vm__' + hostname, 'tag:' + tag, value) backend.hset('vmpooler__vm__' + hostname, 'tag:' + tag, value)
backend.hset('vmpooler__tag__' + Date.today.to_s, hostname + ':' + tag, value) backend.hset('vmpooler__tag__' + Date.today.to_s, hostname + ':' + tag, value)
end
end end
end end