-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[POC][WIP] Make use of platform column to further increase the speed of #allowed_templates #18354
Conversation
@miq-bot add_label performance @kbrock (and maybe @Fryguy): More 🍅 🍅 🍅 for this one (and related ManageIQ/manageiq-schema#322 ) |
a123f90
to
a4ea2b0
Compare
This pull request is not mergeable. Please rebase and repush. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good
|
||
# only fetch the ems if not fetched previously | ||
unless @_ems_allowed_templates_cache.key?(vm_or_template[:ems_id]) | ||
@_ems_allowed_templates_cache[ems_id] = ExtManagementSystem.find(ems_id).try(:name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will we have a bunch of EMSes?
If so, would it make sense to collecting the :ems_id
values first and make a single query?
I'm guessing you already looked at this and deemed it unnecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ugh - ignore this - we already discussed
end | ||
end | ||
|
||
MiqPreloader.preload(allowed_templates_list, [:snapshots, :operating_system, :ext_management_system, {:hardware => :disks}]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yay getting rid of this
if vm_or_template[:operating_system_product_name] | ||
data_hash[:operating_system] = MiqHashStruct.new(:product_name => vm_or_template[:operating_system_product_name]) | ||
end | ||
# TODO: solve owning_blue_folder for the "Hash method" (if needed...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
owning_blue_folder
tends to be a performance issue in lots of places
I agree that we should not address here
This pull request has been automatically closed because it has not been updated for at least 6 months. Feel free to reopen this pull request if these changes are still valid. Thank you for all your contributions! |
Opening this one up for now, but really not going to start much with it for now. Discussion is still going on in ManageIQ/manageiq-schema#322 for the time being. Might rebase out the stuff that was merged with #18353 however... |
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 |
a4ea2b0
to
fe57a37
Compare
This significantly improves the speed of the method by: - Avoiding instantiating intermediate `ActiveRecord` objects that are just garbage collected - Reusing hash results to create the `MiqHashStruct` instantiate Benchmarks ---------- This tests against a AWS EMS with 100k+ templates (public images): **Before** | ms | queries | query (ms) | rows | | ---: | ---: | ---: | ---: | | 14344 | 33 | 1759.6 | 243133 | | 14631 | 33 | 1729.0 | 243133 | | 13405 | 33 | 1752.3 | 243133 | **After** | ms | queries | query (ms) | rows | | ---: | ---: | ---: | ---: | | 4102 | 33 | 1751.3 | 243133 | | 4124 | 33 | 1787.1 | 243133 | | 4133 | 33 | 1746.9 | 243133 |
Checked commits NickLaMuro/manageiq@d78171a~...fe57a37 with ruby 2.5.5, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 |
This pull request has been automatically closed because it has not been updated for at least 3 months. Feel free to reopen this pull request if these changes are still valid. Thank you for all your contributions! More information about the ManageIQ triage process can be found in the traige process documentation. |
REQUIRES ManageIQ/manageiq-schema#322 TO FUNCTION PROPERLY
(Will also require a pre-requisite PR to properly add before save hooks to models)
By adding a few key
virtual_attributes
, we are able to process over 100k records forMiqProvisionVirtWorkflow#allowed_templates
in under 5 seconds, and use very limited memory. There are still a few things required to make this work in all cases, but the main changes required after the update include:virtual_delegate :platform
to avoid preloading ofOperatingSystem
records forVmOrTemplate
records.MiqHashStruct
resultsBenchmarks
Note, metrics are taken only around the
#allowed_templates
method, so extra memory and time to process the rest of the request is not currently being shown.PR #18353 Improvements
Memory: ~1.2Gigs
After switching to
virtual_delegate :platform
inSELECT
Memory: ~900MB
After skipping
ActiveRecord
objectsMemory: ~400MB
TODO
Links
Steps for Testing/QA
Just like #18353 I was using a combination of this script for testing the full routes:
And this one, which tested
MiqProvisionVirtWorkflow#allowed_templates
on it's own: