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

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.

diff --git a/lib/discourse.rb b/lib/discourse.rb
index 6d188b9..ea2a3cb 100644
--- a/lib/discourse.rb
+++ b/lib/discourse.rb
@@ -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
 
     [

GitHub sha: f05f5fde

This commit appears in #13041 which was approved by davidtaylorhq. It was merged by SamSaffron.