Skip to content

Commit 7d7e7e8

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 7d7e7e8

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

crowbar_framework/app/models/service_object.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,36 @@ 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, these priorities come
928+
# from element_run_list_order
929+
#
930+
# In other words: it's actually reducing the number of times chef-client
931+
# is run rather than speeding up execution of any single run, by
932+
# merging batches together
933+
#
934+
# a batch is [roles, nodes]
935+
def merge_batches(batches)
936+
merged_batches = []
937+
unless batches.empty?
938+
current_batch = batches[0]
939+
batches[1..-1].each do |next_batch|
940+
if next_batch[1] == current_batch[1] && !current_batch[0].nil?
941+
current_batch[0] << next_batch[0]
942+
next
943+
end
944+
merged_batches << current_batch
945+
current_batch = next_batch
946+
end
947+
merged_batches << current_batch
948+
end
949+
merged_batches
950+
end
951+
922952
#
923953
# After validation, this is where the role is applied to the system The old
924954
# instance (if one exists) is compared with the new instance. roles are
@@ -1171,6 +1201,8 @@ def apply_role(role, inst, in_queue, bootstrap = false)
11711201

11721202
batches << [roles, nodes_in_batch] unless nodes_in_batch.empty?
11731203
end
1204+
1205+
batches = merge_batches(batches)
11741206
Rails.logger.debug "batches: #{batches.inspect}"
11751207

11761208
# Cache attributes that are useful later on

0 commit comments

Comments
 (0)