PERF: Preload JsLocaleHelper.load_translations for default locale. (#13041)

In production, each Unicorn child process will currently hold the
default locale in memory on first load. Instead, we should preload it in
the Unicorn master process so that the memory is immediately shared when
forking.

Also, the translations are only memoized on first load now and is
adding considerable overhead to the first few requests after a fresh
boot.
This commit is contained in:
Alan Guo Xiang Tan 2021-05-13 14:16:01 +08:00 committed by GitHub
parent 034a0493e3
commit f05f5fde0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -933,6 +933,8 @@ module Discourse
# this will force Cppjieba to preload if any site has it
# enabled allowing it to be reused between all child processes
Search.prepare_data("test")
JsLocaleHelper.load_translations(SiteSetting.default_locale)
end
[