Do not use too many theme html files in Diazo

I have just noticed that when we have too many <theme href="..." /> tags in Diazo, it impacts quite badly the performances.
I usually prefer to manage all my templates separately (home.html, regular.html, dashboard.html, etc., that's easier for the design team), but on a recent project I had more than 10 different templates, and I had big memory problems.

So it is apparently better to have less HTML templates gathering different layouts and just <drop /> what we don't need according the context.

2 Likes

I can confirm, we seen this behavior in a lot of projects. As soon as you switch from one theme to two you'll see a memory (and CPU usage) issue.

Working with a very complicated rules.xml lead me to this PR:

In short words you can cache diazo team compilation in foreground mode setting the environment variable DIAZO_ALWAYS_CACHE_RULES to a non empty value.

It is already released in plone.app.theming 1.3.0

1 Like

Nice! Thanks.

So that means the slowness you mentioned occurred only in development mode, @ebrehault?

Yes absolutely, only on dev mode fortunately. But still, that's very annoying when you try to work on the design and you want to refresh your page fast.

@ebrehault are you sure it it's only development mode? On development mode the issue is a lot worst (although the @alert's fix will probably help) but in our experience it's a problem also on production.

In our experience refactoring a complex Plone 4.3 theme from 8 different directives to only one, greatly enhanced the diazo speed.

@keul the amount of different HTML files involved should not impact the performances because at compile time, all the HTML are aggregated in a unique XSLT stylesheet (where the rules are injected as XSLT code).

So, per se, it should make no difference if the resulting XSLT is the produce of one or many HTML files.
But, what could really make a difference is the complexity of the XSLT processing (which depend on the rules), and maybe the way your Diazo was before refactoring produced a more complex XSLT stylesheet at the end.

That's actually quite difficult to estimate.

@keul, you can benchmark the transform using the command line tools:

  • bin/diazocompiler
  • bin/diazopreprocessor
  • bin/diazorun

This can give you numbers.

More on this:

I think @giacomos knows something about this.

2 Likes