-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
Skip expensive smarty Processing when nothing to see here #16731
Conversation
(Standard links)
|
7557090
to
f637027
Compare
On digging into speed & disk use issues I find that significant disk space is being used on smartyProcessing of greetings. The same also seems to be true of display names. This is a first shot across the bows but I'm also investigating 1) also doing an early return before replaceGreetingTemplate 2) changing the smarty ->fetch call to pass 'eval' rather than string. Despite the gut-reaction the docs identify this as correct https://www.smarty.net/docs/en/resources.string.tpl and eval is not eval From my local profiling this code also kicks in on delete & it's likely we will actually see a decrease in overall test time on this
f637027
to
1441a37
Compare
Ok - I added a sentence to the test docblock |
I have not run this but looks ok from r-code perspective |
test this please |
Steps to test are pretty much to edit a contact & check greetings look OK |
Note we deployed this in production. It has made a significant difference to how many files are now in the templates c directory |
test this please |
Betty and I are reviewing PRs and we came across this one. Steps to reproduce
Review
@eileenmcnaughton we think you need to do some additional work on this issue as could not enter the |
test this please |
@jaapjansma I have updated the PR comments a bit - this is really about mitigating the performance and disk use impact of an old change to add an undocumented feature - ie 73d64eb I don't really want to get into documenting that feature given that it is not created by this PR, or solving the fact that it can't be configured via the UI which is mostly part of that feature - but I can propose a variant that can be saved via the UI - Note that the 'normal' tokens like {contact.first_name} are CiviCRM tokens NOT smarty tokens so by the time the early return is hit they have already been removed. It is only sites that have had a site builder configure smarty The goal here is to make it so supporting the smarty parsing feature doesn't cause negative impact on other sites that don't use it. The result of parsing smarty tokens here is that every contact you edit will create a file on disk with their name just to parse smarty tokens. Perhaps 2% of sites actually have Smarty tokens here. For sites that process 10s of thousands of contacts a day that is 10s of thousands of files created in templates_c |
Agree this is now ok |
Overview
This addresses a speed & disk use issue by not calling smarty in greeting processing when there are no tokens to process. It is a performance fix and a disk usage fix
The call to Smarty occurs AFTER civi tokens are processed - so in addition to parsing the tokens that will be present on most sites there are a small number of sites that implement actual smarty tokens like {if} in their address greetings. This is a feature that was implemented back in 4.2 73d64eb
to support German greetings.
Before
Smarty called on every contact create, edit, ?delete? to get tokens.
After
Smarty only called when there is a '{' present - otherwise we can assume it has nothing to do
No change in results
Technical Details
On digging into speed & disk use issues I find that significant disk space is being
used on smartyProcessing of greetings. The same also seems to be true of display names. This is
a first shot across the bows but I'm also investigating
Despite the gut-reaction the docs identify this as correct
https://www.smarty.net/docs/en/resources.string.tpl and eval is not eval
From my local profiling this code also kicks in on delete & it's likely we will actually
see a decrease in overall test time on this
Comments