Skip to content

XWIKI-11112: Adding a rendering cache to the Icon Theme Application #4339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

michitux
Copy link
Contributor

Jira URL

https://jira.xwiki.org/browse/XWIKI-11112

Changes

Description

  • Introduce the internal concept of an IconTemplateRenderer.
  • Add an internal IconTemplateRendererManager that provides icon template renderers and caches them.
  • Cache parsed Velocity code.
  • Add special cases for the most commonly used Velocity scripts to avoid expensive Velocity execution for those cases.
  • Adapt and add tests.
  • Decrease the expected code coverage to 0.96 as 0.97 is just unrealistic.
  • Don't ask for non-existing components in the extended URL reference serializer. Instead, check if the component exists, first. This speeds up getting the WebJar URL for Font Awesome by about a factor of 5.

Clarifications

  • The last item/second commit could also be a separate Jira or a [Misc] commit, let me know if you want that more formal approach.
  • I chose the approach of just caching the template, not caching the rendered output to avoid having to deal with cache invalidations. Further, I've added special cases to avoid Velocity rendering completely for Font Awesome.
  • Some numbers of loading all icons for the icon picker (see also https://jira.xwiki.org/browse/XWIKI-22540):
Icon theme Before After
Font Awesome 283ms 20ms
Silk (first) 10s 8.67s
Silk (cached) 770ms 330ms

We could decrease the cached running time of Silk further (might be another factor 2) by adding another special case to detect the calls $xwiki.getSkinFile("icons/silk/${icon}.png") but I'm not sure if it is worth the extra complexity.

The fraction of icon rendering of page loads went down from approximately 10% to 1% with Font Awesome. The remaining part is all about generating the WebJar URL.

Screenshots & Video

No UI changes.

Executed Tests

Built the changed modules with quality profile. Performed manual tests (see also above).

Expected merging strategy

  • Prefers squash: Yes
  • Backport on branches:
    • Not sure, might be nice for performance, but the code is not completely trivial.

michitux added 2 commits June 27, 2025 17:57
* Introduce the internal concept of an `IconTemplateRenderer`.
* Add an internal IconTemplateRendererManager that provides icon
  template renderers and caches them.
* Cache parsed Velocity code.
* Add special cases for the most commonly used Velocity scripts to avoid
  expensive Velocity execution for those cases.
* Adapt and add tests.
* Decrease the expected code coverage to 0.96 as 0.97 is just
  unrealistic.
* Don't ask for non-existing components in the extended URL reference
 serializer. Instead, check if the component exists, first. This speeds
 up getting the WebJar URL for Font Awesome by about a factor of 5.
@michitux michitux self-assigned this Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant