Defect #40610
closedSlow display of projects list when including project description column
Added by James H 6 months ago. Updated 6 months ago.
0%
Description
Hello,
I am in the process of upgrading to 5.x.x from 4.x.x and noticed that there was a change to the projects page that is causing me problems, probably due to my open project count.
I have a lot of open projects at a given time and the changes are causing it to lag out and freeze before it finishes loading...
I managed to make it a bit better by removing all the project descriptions and filtering from the page but it also still freezes near the end.
Any way to make this more performant?
Files
40610.patch (2.2 KB) 40610.patch | Go MAEDA, 2024-04-25 02:25 | ||
40610-v2.patch (1009 Bytes) 40610-v2.patch | Go MAEDA, 2024-04-25 08:42 |
Related issues
Updated by Go MAEDA 6 months ago
Does the following change improve performance?
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 910f1f431..24160641b 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -941,7 +941,7 @@ module ApplicationHelper
if obj.is_a?(Journal)
attachments += obj.journalized.attachments if obj.journalized.respond_to?(:attachments)
else
- attachments += obj.attachments if obj.respond_to?(:attachments)
+ attachments += obj.attachments if !obj.is_a?(Project) && obj.respond_to?(:attachments)
end
if attachments.present?
text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png|webp))"(\s+alt="([^"]*)")?/i) do |m|
Updated by Go MAEDA 6 months ago
James H wrote in #note-2:
Go MAEDA wrote in #note-1:
Does the following change improve performance?
[...]
yes, that seems to make it load much much faster, taking about 10% of the time it used to take to freeze
Thank you!
Thanks to your feedback, I have identified the cause of the issue you mentioned. I will look into ways to address this issue.
Updated by Go MAEDA 6 months ago
- File 40610.patch 40610.patch added
- Target version set to Candidate for next minor release
I wrote a patch to fix this issue.
The cause of the issue is that the projects list with the list style loads all attachments whose container_type is Project for each project to render the project's description. Attachments with container_type of Project are files uploaded to the "Files" module.
Attachment Load (0.1ms) SELECT "attachments".* FROM "attachments" WHERE "attachments"."container_id" = ? AND "attachments"."container_type" = ? ORDER BY attachments.created_on ASC, attachments.id ASC [["container_id", 1], ["container_type", "Project"]] ↳ app/helpers/application_helper.rb:944:in `+' Attachment Load (0.2ms) SELECT "attachments".* FROM "attachments" WHERE "attachments"."container_id" = ? AND "attachments"."container_type" = ? ORDER BY attachments.created_on ASC, attachments.id ASC [["container_id", 5], ["container_type", "Project"]] ↳ app/helpers/application_helper.rb:944:in `+' Attachment Load (0.1ms) SELECT "attachments".* FROM "attachments" WHERE "attachments"."container_id" = ? AND "attachments"."container_type" = ? ORDER BY attachments.created_on ASC, attachments.id ASC [["container_id", 6], ["container_type", "Project"]] ↳ app/helpers/application_helper.rb:944:in `+' Attachment Load (0.1ms) SELECT "attachments".* FROM "attachments" WHERE "attachments"."container_id" = ? AND "attachments"."container_type" = ? ORDER BY attachments.created_on ASC, attachments.id ASC [["container_id", 3], ["container_type", "Project"]] ↳ app/helpers/application_helper.rb:944:in `+' Attachment Load (0.1ms) SELECT "attachments".* FROM "attachments" WHERE "attachments"."container_id" = ? AND "attachments"."container_type" = ? ORDER BY attachments.created_on ASC, attachments.id ASC [["container_id", 4], ["container_type", "Project"]] ↳ app/helpers/application_helper.rb:944:in `+' Attachment Load (0.2ms) SELECT "attachments".* FROM "attachments" WHERE "attachments"."container_id" = ? AND "attachments"."container_type" = ? ORDER BY attachments.created_on ASC, attachments.id ASC [["container_id", 2], ["container_type", "Project"]] ↳ app/helpers/application_helper.rb:944:in `+' Rendered projects/_list.html.erb (Duration: 188.8ms | Allocations: 68634)
The reason attachments are loaded to render text content is to generate HTML tags for inline images. Currently, however, attachments are always loaded even for content that does not contain inline images. This causes the performance issue when displaying many projects in the project list.
The attached patch resolves this performance issue by changing ApplicationHelper#parse_inline_attachments to load attachments only when the text being rendered contains img tags. I guess the change will improve performance not only for displaying the projects list, but also for displaying an issue with large numbers of attachments and comments.
Updated by Go MAEDA 6 months ago
- Related to Feature #29482: Query system for Projects page added
Updated by Go MAEDA 6 months ago
- File 40610-v2.patch 40610-v2.patch added