Project

General

Profile

Actions

Feature #42673

closed

Optimize `Version::FixedIssuesExtension#issues_progress` by avoiding repeated `Issue#closed?` calls

Added by Go MAEDA 5 days ago. Updated 4 days ago.

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

0%

Estimated time:
Resolution:
Fixed

Description

The issues_progress(open) method in Version::FixedIssuesExtension calls Issue#closed? inside a loop to determine whether each issue is open or closed. This leads to redundant database queries to fetch IssueStatus records, even though the issues are already filtered by status using the open argument via the self.open(open) scope.

Since the method already knows whether it is iterating over open or closed issues based on the open argument, this closed? check is unnecessary. This patch replaces the condition c.closed? ? 100 : (c.done_ratio || 0) with logic that uses the open flag directly, avoiding unnecessary calls to Issue#closed? and reducing database queries.

This improves performance, especially when processing a large number of issues.
For example, when rendering the /roadmap page with 60 versions and 3000 issues:

Without applying the patch:

Completed 200 OK in 2018ms (Views: 1833.5ms | ActiveRecord: 78.2ms (9539 queries, 9181 cached) | GC: 204.2ms)
Completed 200 OK in 1987ms (Views: 1827.9ms | ActiveRecord: 64.3ms (9539 queries, 9181 cached) | GC: 176.4ms)
Completed 200 OK in 1993ms (Views: 1848.0ms | ActiveRecord: 62.4ms (9539 queries, 9181 cached) | GC: 177.8ms)
Completed 200 OK in 1995ms (Views: 1832.9ms | ActiveRecord: 64.8ms (9539 queries, 9181 cached) | GC: 175.3ms)
Completed 200 OK in 1988ms (Views: 1828.8ms | ActiveRecord: 63.8ms (9539 queries, 9181 cached) | GC: 179.0ms)

With applying the patch:

Completed 200 OK in 1714ms (Views: 1558.2ms | ActiveRecord: 61.6ms (6537 queries, 6185 cached) | GC: 163.7ms)
Completed 200 OK in 1660ms (Views: 1512.0ms | ActiveRecord: 55.8ms (6537 queries, 6185 cached) | GC: 153.8ms)
Completed 200 OK in 1785ms (Views: 1629.3ms | ActiveRecord: 62.5ms (6537 queries, 6185 cached) | GC: 182.6ms)
Completed 200 OK in 1681ms (Views: 1524.1ms | ActiveRecord: 61.6ms (6537 queries, 6185 cached) | GC: 160.8ms)
Completed 200 OK in 1719ms (Views: 1563.3ms | ActiveRecord: 68.3ms (6537 queries, 6185 cached) | GC: 179.1ms)


Files

42673.patch (569 Bytes) 42673.patch Go MAEDA, 2025-05-05 10:15
Actions #1

Updated by Go MAEDA 5 days ago

Here is a patch.

Actions #2

Updated by Go MAEDA 4 days ago

  • Target version set to 6.1.0
Actions #3

Updated by Go MAEDA 4 days ago

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

Committed the patch in r23747.

Actions

Also available in: Atom PDF