-
Notifications
You must be signed in to change notification settings - Fork 1k
Fixes #38275 - Capsules index page may takes long time to load #10473
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
base: develop
Are you sure you want to change the base?
Conversation
Based on my local test,, "SmartProxy.preload" appears to be the better choice.
Eager load performance:
VS preload performance
|
Test results of
Test results of
|
2bdff40
to
04b834d
Compare
Capsules index page may takes up to 1 minute to load when there are many organizations and thousands of locations assigned to every capsules.
04b834d
to
17788d9
Compare
@@ -6,7 +6,10 @@ class SmartProxiesController < ApplicationController | |||
before_action :find_status, :only => [:ping, :tftp_server] | |||
|
|||
def index | |||
@smart_proxies = resource_base_search_and_page.includes(:features) | |||
# Large content_counts data may cause slow page load, especially with eager load. |
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.
Does the api controller suffer from the same slowness?
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.
no. I think api controller doesn't do eager load.
@smart_proxies = resource_base_search_and_page.includes(:features) | ||
# Large content_counts data may cause slow page load, especially with eager load. | ||
# So exclude this field since it is not used in index page. | ||
needed_columns = SmartProxy.attribute_names.reject { |name| name == "content_counts" } |
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.
Iirc content_counts column on the smart_proxies table is something that comes from katello. It feels weird to accomodate for it from here. Could the exclusion be handled in katello instead?
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.
I think just make the change from "eager_load" to "preload" was enough to improve the performance significantly. Excluding the "content_count" is just to make it much better.
I can remove the "content_count" part in this patch. What do you think?
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.
Here is the test data
Loading production environment (Rails [6.1.7.8](http://6.1.7.8/))
Switch to inspect mode.
Benchmark.measure{ capsules = SmartProxy.preload(:organizations, :locations, :features).search_for("").all.to_a; p capsules.size }
8
#<Benchmark::Tms:0x000055d0f35e8868 @label="", @real=0.21791561204008758, @cstime=0.0, @cutime=0.0, @stime=0.008923000000000236, @utime=0.14369000000000298, @total=0.15261300000000322>
Benchmark.measure{ capsules = SmartProxy.preload(:organizations, :locations, :features).search_for("", order: "name desc").all.to_a; p capsules.size }
8
#<Benchmark::Tms:0x000055d0f45e6968 @label="", @real=0.10522056301124394, @cstime=0.0, @cutime=0.0, @stime=0.0041479999999998185, @utime=0.05878600000000134, @total=0.06293400000000116>
Benchmark.measure{ capsules = SmartProxy.preload(:organizations, :locations, :features).search_for("name = capsule01.example.com").all.to_a; p capsules.size }
1
#<Benchmark::Tms:0x000055d0f48948b8 @label="", @real=0.0292418641038239, @cstime=0.0, @cutime=0.0, @stime=0.0008479999999995158, @utime=0.019142000000002213, @total=0.01999000000000173>
Benchmark.measure{ capsules = SmartProxy.preload(:organizations, :locations, :features).search_for("organization = TestOrg1").all.to_a; p capsules.size }
8
#<Benchmark::Tms:0x000055d0f6a888c0 @label="", @real=1.073761180974543, @cstime=0.0, @cutime=0.0, @stime=0.10191399999999984, @utime=0.30263300000000015, @total=0.404547>
Benchmark.measure{ capsules = SmartProxy.preload(:organizations, :locations, :features).search_for("organization = TestOrg2", order: "name desc").all.to_a; p capsules.size }
8
#<Benchmark::Tms:0x000055d0f6d04298 @label="", @real=1.4741708659566939, @cstime=0.0, @cutime=0.0, @stime=0.033474000000000004, @utime=0.7390229999999995, @total=0.7724969999999995>
Benchmark.measure{ capsules = SmartProxy.preload(:organizations, :locations, :features).search_for("location = TestLocation1").all.to_a; p capsules.size }
8
#<Benchmark::Tms:0x000055d0ea625758 @label="", @real=1.1359932541381568, @cstime=0.0, @cutime=0.0, @stime=0.027599000000000373, @utime=0.41822099999999907, @total=0.44581999999999944>
Capsules index page may takes up to 1 minute to load when there are many organizations and thousands of locations assigned to every capsules.