Project

General

Profile

Actions

Defect #44348

closed

Formatting a text is much slower in 7.0.0 when its container has many attachments

Added by Go MAEDA 22 days ago. Updated 19 days ago.

Status:
Closed
Priority:
Normal
Category:
Performance
Target version:
Resolution:
Fixed
Affected version:

Description

Since 7.0.0, formatting text takes much longer when its container has many attachments. This affects everything rendered through ApplicationHelper#textilizable: wiki pages, issue descriptions and notes, forum messages, news, and documents.

The reason is that Formatter#to_html calls the expensive post_processor_scrubbers method inside the loop that runs once per HTML node. This seems to be a regression introduced by #43745.

Formatting text with 123 nodes in a container with 100 attachments, measured with the attached benchmark script:

  6.1.3, Ruby 3.2.2        3.2 ms   10565 objects allocated
  7.0.0, Ruby 3.4.8       29.4 ms   25052 objects allocated
  7.0.0 with the patch     2.9 ms   13286 objects allocated

The attached patch builds the scrubbers once per text instead of once per node. This restores the rendering time to the 6.1 level. Text with no attachments is unaffected. The Textile formatter has the same problem and is fixed in the same way.


Files

Actions #1

Updated by Marius BĂLTEANU 20 days ago

  • Status changed from New to Resolved
  • Assignee set to Marius BĂLTEANU
  • Resolution set to Fixed

Thanks Go MAEDA for catching and fixing this issue!

Actions #2

Updated by Marius BĂLTEANU 19 days ago

  • Status changed from Resolved to Closed

Merged the fix.

Actions

Also available in: Atom PDF