Project

General

Profile

Actions

Defect #40610

closed

Slow display of projects list when including project description column

Added by James H 8 months ago. Updated 7 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Performance
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

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

Related to Redmine - Feature #29482: Query system for Projects pageClosedJean-Philippe Lang

Actions
Actions #1

Updated by Go MAEDA 8 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|
Actions #2

Updated by James H 8 months ago

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!

Actions #3

Updated by Go MAEDA 8 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.

Actions #4

Updated by Go MAEDA 8 months ago

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.

Actions #5

Updated by Go MAEDA 8 months ago

  • Affected version changed from 5.1.2 to 4.1.0
Actions #6

Updated by Go MAEDA 8 months ago

Actions #7

Updated by Go MAEDA 8 months ago

I found a simpler solution than the patch I posted in #note-4. Applying the following fix will have the same effect as the patch in #note-4, as it will skip processing inline images, which is not necessary when displaying the project list.

Actions #8

Updated by James H 8 months ago

Thank you, will give it a try later

Actions #9

Updated by Go MAEDA 8 months ago

  • Target version changed from Candidate for next minor release to 5.0.9

Setting the target version to 5.0.9.

Actions #10

Updated by Go MAEDA 7 months ago

  • Subject changed from Projects page never finishes loading to Slow display of projects list when including project description column
  • Status changed from New to Resolved
  • Resolution set to Fixed

Committed the fix in r22829.

Actions #11

Updated by Go MAEDA 7 months ago

  • Status changed from Resolved to Closed
  • Assignee set to Go MAEDA

Merged the change to stable branches.

Actions

Also available in: Atom PDF