Skip to content

Conversation

@tvdeyen
Copy link
Member

@tvdeyen tvdeyen commented Jan 29, 2026

What is this pull request for?

Pre-compute URL templates once at the class level and substitute page IDs
using simple string operations instead of calling Rails URL helpers for
each page. This reduces the overhead of route matching which was showing
up as a significant portion of render time in profiling.

For a tree with 1000 pages, this reduces render time from ~725ms to ~420ms
(approximately 40% improvement).

Cache repeated translation lookups in a frozen hash at the class level.
Translations like "Your user role does not allow you to edit this page"
were being looked up 6 times per page (6000 times for 1000 pages).

Combined with the URL optimization, render time for 1000 pages improves
from ~725ms to ~330ms (approximately 54% faster).

Checklist

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have added tests to cover this change

@tvdeyen tvdeyen added the performance Performance improvement label Jan 29, 2026
@tvdeyen tvdeyen added this to the 8.1 milestone Jan 29, 2026
@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.47%. Comparing base (b6a826e) to head (a1b9e28).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3606   +/-   ##
=======================================
  Coverage   97.47%   97.47%           
=======================================
  Files         314      314           
  Lines        8228     8240   +12     
=======================================
+ Hits         8020     8032   +12     
  Misses        208      208           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Pre-compute URL templates once at the class level and substitute page IDs
using simple string operations instead of calling Rails URL helpers for
each page. This reduces the overhead of route matching which was showing
up as a significant portion of render time in profiling.

For a tree with 1000 pages, this reduces render time from ~725ms to ~420ms
(approximately 40% improvement).
Cache repeated translation lookups in a frozen hash at the class level.
Translations like "Your user role does not allow you to edit this page"
were being looked up 6 times per page (6000 times for 1000 pages).

Combined with the URL optimization, render time for 1000 pages improves
from ~725ms to ~330ms (approximately 54% faster).
@tvdeyen tvdeyen force-pushed the page-tree-rendering-perf branch from 076b2f9 to a1b9e28 Compare January 29, 2026 17:07
@tvdeyen tvdeyen marked this pull request as ready for review January 29, 2026 17:07
@tvdeyen tvdeyen requested a review from a team as a code owner January 29, 2026 17:07
@tvdeyen tvdeyen merged commit 8bae906 into main Jan 29, 2026
22 checks passed
@tvdeyen tvdeyen deleted the page-tree-rendering-perf branch January 29, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants