From 0a323f6052fcb08e885950f525b6f87df027425a Mon Sep 17 00:00:00 2001 From: Samuel Date: Fri, 23 Oct 2020 11:40:11 -0500 Subject: [PATCH] (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 --- lib/vmpooler/api/helpers.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/vmpooler/api/helpers.rb b/lib/vmpooler/api/helpers.rb index 1fd4325..a667dcb 100644 --- a/lib/vmpooler/api/helpers.rb +++ b/lib/vmpooler/api/helpers.rb @@ -114,11 +114,13 @@ module Vmpooler end def export_tags(backend, hostname, tags) - tags.each_pair do |tag, value| - next if value.nil? or value.empty? + backend.pipelined do + tags.each_pair do |tag, value| + next if value.nil? or value.empty? - backend.hset('vmpooler__vm__' + hostname, 'tag:' + tag, value) - backend.hset('vmpooler__tag__' + Date.today.to_s, hostname + ':' + tag, value) + backend.hset('vmpooler__vm__' + hostname, 'tag:' + tag, value) + backend.hset('vmpooler__tag__' + Date.today.to_s, hostname + ':' + tag, value) + end end end