Defect #43446
openCommonMark rendering became significantly slower after #42737
Added by Katsuya HIDAKA 1 day ago. Updated about 20 hours ago.
0%
Description
After applying the changes from #42737, CommonMark rendering (issue descriptions, comments, wiki, etc.) has become much slower. Measuring before and after that change shows a slowdown of about 6x.
Since CommonMark rendering is used frequently across Redmine, this regression affects the overall responsiveness of the application.
Benchmark results¶
| Revision | Avg per render |
|---|---|
| r24093 (before #42737) | 23.90 ms |
| r24097 (after #42737) | 148.99 ms |
Benchmark script¶
bin/rails r commonmark_bench.rb
commonmark_bench.rbcommonmark_bench.rb
# frozen_string_literal: true
require "benchmark"
Setting.text_formatting = "common_mark"
Setting.cache_formatted_text = 0
ITERATIONS = 10
# Content of https://www.redmine.org/projects/redmine/wiki converted to CommonMark
SAMPLE_TEXT = <<TEXT
# Redmine
Redmine is a flexible project management web application. Written using the Ruby on Rails framework, it is cross-platform and cross-database.
Redmine is open source and released under the terms of the [GNU General Public License v2](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) (GPL).
## Features
Some of the main features of Redmine are:
- [[RedmineProjects|Multiple projects support]]
- Flexible [[RedmineRoles|role based access control]]
- Flexible [[RedmineIssues|issue tracking system]]
- [[RedmineGantt|Gantt chart]] and [[RedmineCalendar|calendar]]
- [[RedmineNews|News]], [[RedmineDocuments|documents]] & [[RedmineFiles|files]] management
- Feeds & email notifications
- Per project [[RedmineWikis|wiki]]
- Per project [[RedmineForums|forums]]
- [[RedmineTimeTracking|Time tracking]]
- [[RedmineCustomFields|Custom fields]] for issues, time-entries, projects and users
- [[RedmineRepository|SCM integration]] (SVN, CVS, Git, Mercurial and Bazaar)
- [[RedmineReceivingEmails|Issue creation via email]]
- Multiple [[RedmineLDAP|LDAP authentication]] support
- [[RedmineRegister|User self-registration]] support
- Multilanguage support
- [[RedmineInstall#Supported-database-back-ends|Multiple databases]] support
Read more about [[Features|Redmine features]].
## Documentation
You can read the **[[Guide|Redmine guide]]**.
- [[Guide|User's Guide]]
- [[Developer_Guide|Developer's Guide]]
- [DeepWiki Documentation](https://deepwiki.com/redmine/redmine (Auto-generated by DeepWiki))
Other resources:
- [[Changelog]]
- [[Security Advisories]]
- [[FAQ|Frequently Asked Questions]]
- [[HowTos]]
- [[Plugins]]
- [[Themes]]
- [[Logo|Logo and Icon]]
- [[ThirdPartyTools|Third Party Tools]]
## Online demo
A shared online *unofficial* demo site can be found at https://demo.redminecloud.net/. It has been set up to give registered users the ability to create their own projects. This means that once you register, you can create your own project on there and try out the project administration features. Please note that this demo site is an unofficial, third-party site and has no connection to Redmine.org.
## Support & getting help
For getting help or discussing Redmine, you can browse the [Redmine forums](http://www.redmine.org/projects/redmine/boards) hosted right here in Redmine.
We also have a **[[IRC|chatroom]]** - [join #redmine](https://web.libera.chat/?channel=#redmine) on the [libera.chat](https://libera.chat) IRC network.
There's also an unofficial workspace on **[Slack](https://join.slack.com/t/redmineorg/shared_invite/zt-ew74bkww-9~Cs~L2oSioRXDljumZ_zg)** where you can ask questions and participate in discussions with other Redmine users.
Before submitting a bug report, a patch or a feature request here, please read the [[Submissions|Submission guidelines]].
## Contributing and helping out
Redmine is built and maintained by community volunteers. If you enjoy using it and would like to give back to the community, the [[Contribute]] page has several ideas. Software development experience is not required. Check out the [[Teams]] Page if you are interested in a specific area to contribute regularly.
You can also make a donation and get listed on the [[Donors|Redmine Donors page]].
## Who uses Redmine?
[[WeAreUsingRedmine|This page lists]] some companies and projects using Redmine.
TEXT
def render_sample
Redmine::WikiFormatting.to_html(
"common_mark",
SAMPLE_TEXT,
object: Issue.new(id: 1),
attribute: :description
)
end
elapsed = Benchmark.realtime do
ITERATIONS.times { render_sample }
end
avg_ms = (elapsed / ITERATIONS) * 1000
puts format("Average: %.2fs ms", avg_ms)
Files
| 0001-Fix-performance-issue.patch (4.31 KB) 0001-Fix-performance-issue.patch | Takashi Kato, 2025-11-07 16:36 |
Updated by Katsuya HIDAKA 1 day ago
It turns out that the rendering becomes even slower when the CommonMark content is larger.
The following results are from running the same benchmark script used for the issue description, but with the CommonMark content tripled in size.
| Revision | Avg per render (10 times) |
|---|---|
| r24093 (before #42737) | 35.57 ms |
| r24094 (after #42737) | 1043.98 ms |
That's about 29.4x slower. From this result, the rendering performance appears to scale worse with larger content than it did before.
Benchmark script (with a slightly modified average calculation):
commonmark_bench_3x_content.rbcommonmark_bench_3x_content.rb
# frozen_string_literal: true
require "benchmark"
Setting.text_formatting = "common_mark"
Setting.cache_formatted_text = 0
ITERATIONS = 10
# Content of https://www.redmine.org/projects/redmine/wiki converted to CommonMark
SAMPLE_TEXT = <<TEXT * 3
# Redmine
Redmine is a flexible project management web application. Written using the Ruby on Rails framework, it is cross-platform and cross-database.
Redmine is open source and released under the terms of the [GNU General Public License v2](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) (GPL).
## Features
Some of the main features of Redmine are:
- [[RedmineProjects|Multiple projects support]]
- Flexible [[RedmineRoles|role based access control]]
- Flexible [[RedmineIssues|issue tracking system]]
- [[RedmineGantt|Gantt chart]] and [[RedmineCalendar|calendar]]
- [[RedmineNews|News]], [[RedmineDocuments|documents]] & [[RedmineFiles|files]] management
- Feeds & email notifications
- Per project [[RedmineWikis|wiki]]
- Per project [[RedmineForums|forums]]
- [[RedmineTimeTracking|Time tracking]]
- [[RedmineCustomFields|Custom fields]] for issues, time-entries, projects and users
- [[RedmineRepository|SCM integration]] (SVN, CVS, Git, Mercurial and Bazaar)
- [[RedmineReceivingEmails|Issue creation via email]]
- Multiple [[RedmineLDAP|LDAP authentication]] support
- [[RedmineRegister|User self-registration]] support
- Multilanguage support
- [[RedmineInstall#Supported-database-back-ends|Multiple databases]] support
Read more about [[Features|Redmine features]].
## Documentation
You can read the **[[Guide|Redmine guide]]**.
- [[Guide|User's Guide]]
- [[Developer_Guide|Developer's Guide]]
- [DeepWiki Documentation](https://deepwiki.com/redmine/redmine (Auto-generated by DeepWiki))
Other resources:
- [[Changelog]]
- [[Security Advisories]]
- [[FAQ|Frequently Asked Questions]]
- [[HowTos]]
- [[Plugins]]
- [[Themes]]
- [[Logo|Logo and Icon]]
- [[ThirdPartyTools|Third Party Tools]]
## Online demo
A shared online *unofficial* demo site can be found at https://demo.redminecloud.net/. It has been set up to give registered users the ability to create their own projects. This means that once you register, you can create your own project on there and try out the project administration features. Please note that this demo site is an unofficial, third-party site and has no connection to Redmine.org.
## Support & getting help
For getting help or discussing Redmine, you can browse the [Redmine forums](http://www.redmine.org/projects/redmine/boards) hosted right here in Redmine.
We also have a **[[IRC|chatroom]]** - [join #redmine](https://web.libera.chat/?channel=#redmine) on the [libera.chat](https://libera.chat) IRC network.
There's also an unofficial workspace on **[Slack](https://join.slack.com/t/redmineorg/shared_invite/zt-ew74bkww-9~Cs~L2oSioRXDljumZ_zg)** where you can ask questions and participate in discussions with other Redmine users.
Before submitting a bug report, a patch or a feature request here, please read the [[Submissions|Submission guidelines]].
## Contributing and helping out
Redmine is built and maintained by community volunteers. If you enjoy using it and would like to give back to the community, the [[Contribute]] page has several ideas. Software development experience is not required. Check out the [[Teams]] Page if you are interested in a specific area to contribute regularly.
You can also make a donation and get listed on the [[Donors|Redmine Donors page]].
## Who uses Redmine?
[[WeAreUsingRedmine|This page lists]] some companies and projects using Redmine.
TEXT
def render_sample
Redmine::WikiFormatting.to_html(
"common_mark",
SAMPLE_TEXT,
object: Issue.new(id: 1),
attribute: :description
)
end
elapsed = Array.new(ITERATIONS) do
Benchmark.realtime { render_sample }
end
avg_ms = (elapsed.sum / ITERATIONS) * 1000
puts format("Average: %.2fs ms", avg_ms)
Updated by Takashi Kato about 20 hours ago
The performance issue was caused by SyntaxHighlightScrubber checking all nodes using a CSS selector and the `matches?` method.
The benchmark results after applying the patch in my environment are as follows:
| r24093: Average: | 34.94s ms |
| r24132: Average: | 1492.66s ms |
| patched: Average: | 48.18s ms |
While the performance is not completely back to its original speed, a significant performance degradation has been avoided.