Skip to content

Commit f038c32

Browse files
author
Sumit Jamgade
committed
Combine batches of successive roles for same nodes,
We can speed-up the application of (n+1)th role if both(n,n+1) roles are being applied on the same node. This speedup of deployment of ceilometer by atleast 1m20s (measured: 90sec) and swift by ~20s. eg. In our 2node deployment ceilometer{server,central} are always applied on the same node, given that they have different priorities, they are to be applied, one after the other. This does not violate any order constraints as the application procedure of (n+1)th role is transparent to the nth role
1 parent 264b1f1 commit f038c32

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

crowbar_framework/app/models/service_object.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,35 @@ def self.proposal_to_role(proposal, bc_name)
919919
RoleObject.new role
920920
end
921921

922+
# we can speed-up the application of (n+1)th role if both(n,n+1)
923+
# roles are being applied on the same node.
924+
#
925+
# eg. In our 2node deployment ceilometer{server,central} are always
926+
# applied on the same node, given that they have different priorities,
927+
# they are to be applied, one after the other.
928+
#
929+
# In other words: it's actually reducing the number of times chef-client
930+
# is run rather than speeding up execution of any single run, by
931+
# merging batches together
932+
#
933+
# a batch is [roles, nodes]
934+
def mergebatches(batches)
935+
merged_batches = []
936+
unless bathces.empty?
937+
current_batch = batches[0]
938+
batches[1..-1].each do |next_batch|
939+
if next_batch[1] == current_batch[1] && !current_batch[0].nil?
940+
current_batch[0] << next_batch[0]
941+
next
942+
end
943+
merged_batches << current_batch
944+
current_batch = next_batch
945+
end
946+
merged_batches << current_batch
947+
end
948+
return merged_batches
949+
end
950+
922951
#
923952
# After validation, this is where the role is applied to the system The old
924953
# instance (if one exists) is compared with the new instance. roles are
@@ -1171,6 +1200,8 @@ def apply_role(role, inst, in_queue, bootstrap = false)
11711200

11721201
batches << [roles, nodes_in_batch] unless nodes_in_batch.empty?
11731202
end
1203+
1204+
batches = mergebatches(batches)
11741205
Rails.logger.debug "batches: #{batches.inspect}"
11751206

11761207
# Cache attributes that are useful later on

0 commit comments

Comments
 (0)