Skip to content

Commit 39b3e6e

Browse files
committed
[miq_provision_virt_workflow.rb] Use VmOrTemplate#platform
Very large performance improvement from this patch on large collections of templates since it avoids preloading all together, reducing the number of iterations over the VM collection, and the number of support objects needing to be introduced (that would later need to be garbage collected. Benchmark --------- **Before** | ms | queries | query (ms) | rows | | ---: | ---: | ---: | ---: | | 27107 | 33 | 1958.5 | 243133 | | 26803 | 33 | 1944.2 | 243133 | | 27642 | 33 | 1965.5 | 243133 | **After** | ms | queries | query (ms) | rows | | ---: | ---: | ---: | ---: | | 14344 | 33 | 1759.6 | 243133 | | 14631 | 33 | 1729.0 | 243133 | | 13405 | 33 | 1752.3 | 243133 |
1 parent 871f2b8 commit 39b3e6e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

app/models/miq_provision_virt_workflow.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,13 @@ def tag_symbol
298298
:vm_tags
299299
end
300300

301-
VM_OR_TEMPLATE_EXTRA_COLS = %i(mem_cpu cpu_total_cores v_total_snapshots allocated_disk_storage).freeze
301+
VM_OR_TEMPLATE_EXTRA_COLS = %i(
302+
platform
303+
mem_cpu
304+
cpu_total_cores
305+
v_total_snapshots
306+
allocated_disk_storage
307+
).freeze
302308
def allowed_templates(options = {})
303309
# Return pre-selected VM if we are called for cloning
304310
if [:clone_to_vm, :clone_to_template].include?(request_type)
@@ -355,7 +361,6 @@ def allowed_templates(options = {})
355361
end
356362
end
357363

358-
MiqPreloader.preload(allowed_templates_list, %i(operating_system))
359364
@_ems_allowed_templates_cache = {}
360365
@allowed_templates_cache = allowed_templates_list.collect do |template|
361366
create_hash_struct_from_vm_or_template(template, options)
@@ -1055,7 +1060,7 @@ def create_hash_struct_from_vm_or_template(vm_or_template, options)
10551060
:evm_object_class => :Vm}
10561061
data_hash[:cloud_tenant] = vm_or_template.cloud_tenant if vm_or_template.cloud_tenant_id
10571062
if vm_or_template.operating_system
1058-
data_hash[:operating_system] = MiqHashStruct.new(:product_name => vm_or_template.operating_system.product_name)
1063+
data_hash[:operating_system] = MiqHashStruct.new(:product_name => vm_or_template.operating_system_product_name)
10591064
end
10601065
if options[:include_datacenter] == true
10611066
data_hash[:datacenter_name] = vm_or_template.owning_blue_folder.try(:parent_datacenter).try(:name)

0 commit comments

Comments
 (0)