(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.
This commit is contained in:
Samuel Beaulieu 2020-10-23 10:29:03 -05:00
parent 981d110bbf
commit 68bc5d5bde

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