Feature #43957
openImprove workflow update performance
Description
When the number of issue statuses grows, updating workflows becomes significantly slower.
The current implementation of WorkflowTransition.replace_transitions loads matching workflow transition records into an array, and then repeatedly searches that array with select method inside nested loops over statuses, rules, trackers, and roles. As the number of statuses increases, this repeated full-array scanning becomes expensive and makes workflow updates noticeably slow.
This patch improves the performance by changing the transition lookup from repeated scans over a large array to hash-based lookup. Existing records are grouped by transition scope first, and later lookups use the grouped hash instead of performing full-array filtering every time. This keeps the change relatively small while reducing the Ruby-side lookup cost substantially.
On my development environment, I measured the following results for WorkflowTransition.replace_transitions:
| statuses | Average time before (sec) | Average time after (sec) | speedup |
|---|---|---|---|
| 10 | 0.0773 | 0.0566 | 1.37x |
| 20 | 0.3747 | 0.1660 | 2.26x |
| 40 | 3.8072 | 0.6849 | 5.56x |
| 80 | 60.7722 | 2.8387 | 21.41x |
Files
No data to display