Project

General

Profile

Actions

Patch #40000

closed

Optimize gantt chart rendering for issues without subtasks

Added by Go MAEDA 4 months ago. Updated 3 months ago.

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

0%

Estimated time:

Description

This patch introduces an optimization to the gantt chart rendering process. We can improve the performance by avoiding unnecessary database queries for issues that do not have subtasks, especially when rendering gantt with large numbers of issues.

The current implementation in the Gantt chart helper performs a database query to fetch children for every issue, regardless of whether the issue has subtasks.

  Issue Load (0.4ms)  SELECT "issues".* FROM "issues" WHERE "issues"."parent_id" = $1 ORDER BY "issues"."lft" ASC  [["parent_id", 1]]
  ↳ lib/redmine/helpers/gantt.rb:768:in `html_subject'
  Issue Load (0.3ms)  SELECT "issues".* FROM "issues" WHERE "issues"."parent_id" = $1 ORDER BY "issues"."lft" ASC  [["parent_id", 15]]
  ↳ lib/redmine/helpers/gantt.rb:768:in `html_subject'
  Issue Load (0.4ms)  SELECT "issues".* FROM "issues" WHERE "issues"."parent_id" = $1 ORDER BY "issues"."lft" ASC  [["parent_id", 16]]
  ↳ lib/redmine/helpers/gantt.rb:768:in `html_subject'
  Issue Load (0.2ms)  SELECT "issues".* FROM "issues" WHERE "issues"."parent_id" = $1 ORDER BY "issues"."lft" ASC  [["parent_id", 17]]
  ↳ lib/redmine/helpers/gantt.rb:768:in `html_subject'
  Issue Load (0.1ms)  SELECT "issues".* FROM "issues" WHERE "issues"."parent_id" = $1 ORDER BY "issues"."lft" ASC  [["parent_id", 18]]

With the patch applied, it first checks if the issue has children by using object.leaf?. If the issue has no children, it avoids the database query to retrieve children. This check can reduce a considerable number of SQL queries.

Below is the test result with 500 issues. All issues don't have subtasks.

Without the patch:

$ hey -n 50 -c 1 http://localhost:3000/projects/ecookbook/issues/gantt 

Summary:
  Total:        19.2706 secs
  Slowest:      0.5254 secs
  Fastest:      0.3520 secs
  Average:      0.3854 secs
  Requests/sec: 2.5946

  Total data:   61809550 bytes
  Size/request: 1236191 bytes

With the patch applied:

$ hey -n 50 -c 1 http://localhost:3000/projects/ecookbook/issues/gantt 

Summary:
  Total:        13.4183 secs
  Slowest:      0.2972 secs
  Fastest:      0.2455 secs
  Average:      0.2684 secs
  Requests/sec: 3.7263

  Total data:   61809550 bytes
  Size/request: 1236191 bytes


Files

40000.patch (687 Bytes) 40000.patch Go MAEDA, 2024-01-03 09:44
Actions #1

Updated by Go MAEDA 4 months ago

Attaching a patch.

Actions #2

Updated by Go MAEDA 4 months ago

  • Target version set to 6.0.0
Actions #3

Updated by Go MAEDA 4 months ago

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

Committed the patch in r22589.

Actions

Also available in: Atom PDF