Skip to content
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

t() checks locale.settings.json for "translate_english" even when it does not exist #444

Closed
quicksketch opened this issue Dec 10, 2014 · 1 comment · Fixed by backdrop/backdrop#574

Comments

@quicksketch
Copy link
Member

While doing some profiling, I found that the t() function can be doing a config_get() call every single time it is called. With t() executed hundreds of times per page, this was resulting in a lot of disk accesses.

The problem is that we're checking config_get('locale.settings', 'translate_english') in t(), but the Locale module might not have been enabled in the first place. This results in locale.settings.json not existing, and the config_get() having to check for the file every request. We should optimize this by:

  • Moving translate_english into system.core.json so it always exists.
  • Statically caching the result of the $translate_english variable in t().
@quicksketch
Copy link
Member Author

PR filed at backdrop/backdrop#574.

This was a pretty grievous performance bug. XHProf before/after on the admin/content page:

t-xhprof

I found that moving the translate_english option to system.core was unnecessary. We can just treat a NULL value as FALSE if Locale module is not enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant